toolman Posted June 27, 2014 Share Posted June 27, 2014 Hi,I have some jQuery tabs. I would like to be able to link to them directly, but I can't work out how to do this.I have the following code: <div class="container-outer"> <div class="container"> <div id="prod-tabs"> <ul class="tabs"> <li class="first_tab"><a href="#tab1">Tab 1</a></li> <li><a href="#tab2">Tab 2</a></li> <li><a href="#tab3">Tab 3</a></li> </ul> </div> <div class="tab_container"> <div id="tab1" class="tab_content"> tab 1 </div> <div id="tab2" class="tab_content"> tab 2 </div> <div id="tab3" class="tab_content"> tab 3 </div> </div> </div> </div> </div> How could I link directly to each of the tabs?Thanks! Link to comment https://forums.phpfreaks.com/topic/289301-link-directly-to-tab/ Share on other sites More sharing options...
kicken Posted June 27, 2014 Share Posted June 27, 2014 You'd need to add some javascript that runs onload an inspects the URL hash value to determine which tab to open. For instance (untested): jQuery(function($){ var tab = location.hash; var $widget = $('#prod-tabs'); $widget.find('a').each(function(idx,ele){ if (ele.href == tab){ $widget.tabs('load', idx); } }); }); Link to comment https://forums.phpfreaks.com/topic/289301-link-directly-to-tab/#findComment-1483272 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.