I want to be able to send users a link that includes a hash that will open a specific tab on that link's page.
However, no matter which hash I place in the URL, that tab is never selected. Clicking the tab buttons work just fine, though.
How can I make a tab active simply by grabbing the hash from the URL?
This is my partial code:
<script>
$('.userhref').click(function(){
$('#nav').find('li').find('a[href=' + $(this).attr('href') + ']').closest('li').addClass('active').siblings('li').removeClass('active');
});
</script>
<div class="tabbable nav-tabs-container" style="max-width:1000px;">
<ul class="nav nav-tabs" id="nav" name="tabs" role="tablist">
<li role="presentation"><a href="#tab1" aria-controls="tab1" role="tab" data-toggle="tab"> Description</a></li>
<li role="presentation"><a href="#tab2" aria-controls="tab2" role="tab" data-toggle="tab"> Specs</a></li>
</ul>
<div class="tab-content">
<div role="tabpanel" class="tab-pane" id="tab1">
<h3>Tab 1</h3>
</div>
<div role="tabpanel" class="tab-pane" id="tab2">
<h3>Tab 2</h3>
</div>
</div>
</div>
The full code and working example can be seen here:
https://www.s22.us/tabs.php#tab3
None of the solutions I've found work in this scenario.
Via Active questions tagged javascript - Stack Overflow https://ift.tt/aX14KBE
Comments
Post a Comment