Reputation: 43
I have a page with four tabs (using jQuery to open the content of each them). They all have id tags like tab1, tab2 etc and the links to select the tab are #tab1, #tab2 etc.
How can I make it so the URL opens a specific tab?
like http://mysite.com/#tab3 will open the same page but select tab3 ?
Thanks
Upvotes: 0
Views: 1223
Reputation: 96
if you are using jQueryUI-tabs:
Just look at the index.html of the jQueryUI-bundle.
It already contains a div to which tabs were added. Each tab is a list-item containing a hyperlink with an anchor as an href-attribute.
When you append the name of the anchor to the URL after index.html, it should open the corresponding tab
(e. g. your-url/index.html#tabs-2 should simply open the second tab)
<div id="tabs">
<ul>
<li><a href="#tabs-1">First</a></li>
<li><a href="#tabs-2">Second</a></li>
<li><a href="#tabs-3">Third</a></li>
</ul>
...
Did you already try that out?
Greetings
netpie
Upvotes: 2