Direct link to jquery Nest Tab

I'm trying to link directly to a nested jquery tab from another page. I want to the user to click a link that takes them to the nested tab. I thought it would as simple as linking to the id, but that didn't work.

Thanks in advance.

Example URL: page.html#tabs-22

<div class="tab-container">
   <div id="tabs">
      <ul>
         <li><a href="#tabs-1">Tab 1</a></li>
         <li><a href="#tabs-2">Tab 2</a></li>
      </ul>
      <div id="tabs-1">
         <div id="tabs1">
            <ul>
               <li><a href="#tabs-11">Tab 1 Sub Tab 1</a></li>
               <li><a href="#tabs-12">Tab 1 Sub Tab 2</a></li>
            </ul>
            <div id="tabs-11">
               <h2>Sub Tab 1</h2>
               <p>Place your tab 1 sub tab 1 text here.</p>
            </div>
            <div id="tabs-12">
               <h2>Sub Tab 2</h2>
               <p>Place your tab 1 sub tab 2 text here.</p>
            </div>
         </div>
      </div>
      <div id="tabs-2">
         <div id="tabs2">
            <ul>
               <li><a href="#tabs-21">Tab 2 Sub Tab 1</a></li>
               <li><a href="#tabs-22">Tab 2 Sub Tab 2</a></li>
            </ul>
            <div id="tabs-21">
               <h2>Sub Tab 1</h2>
               <p>Place your tab 2 sub tab 2 text here.</p>
            </div>
            <div id="tabs-22">
               <h2>Sub Tab 2</h2>
               <p>Place your tab 2 sub tab 2 text here.</p>
            </div>
         </div>
      </div>
   </div>
</div>

Open in new window

kieriosityAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Tom BeckCommented:
Doesn't work automatically with jQuery tabs the way it does with Bootstrap tabs. It can be done however by reading the window.location.hash and setting the active tab accordingly. You must be consistent with your id naming convention, i.e. parent tab: "tabs-1", sub tab: "tabs-11", sub tab: "tabs-12", etc.
$(function() {
	var hash = window.location.hash.substr(6);
	var parentTab = parseInt(hash.charAt(0)) -1;
	var childTab = parseInt(hash.charAt(1)) -1;
        $( "#tabs" ).tabs({active: parentTab});
	$( "#tabs-1" ).tabs({active: (isNaN(childTab)) ? 0 : childTab});
	$( "#tabs-2" ).tabs({active: (isNaN(childTab)) ? 0 : childTab});
  });

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
kieriosityAuthor Commented:
Brilliant. Thank you.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
jQuery

From novice to tech pro — start learning today.