Last active
April 16, 2022 01:02
-
-
Save bnecreative/8c7cc3598a1d18cee246 to your computer and use it in GitHub Desktop.
Deeplink to Bootstrap Tabs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jQuery(document).ready(function($){ | |
// Allow Page URL to activate a tab's ID | |
var taburl = document.location.toString(); | |
if( taburl.match('#') ) { | |
$('.nav-tabs a[href="#'+taburl.split('#')[1]+'"]').tab('show'); | |
} | |
// Allow internal links to activate a tab. | |
$('a[data-toggle="tab"]').click(function (e) { | |
e.preventDefault(); | |
$('a[href="' + $(this).attr('href') + '"]').tab('show'); | |
}); | |
}); // End |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- This is how I structure my bootstrap tabs in my WordPress Themes. Your markup may be different. --> | |
<p>Here's a <a href="#my_tab3" data-toggle="tab">link</a> Jump to Tab #3.</p> | |
<div class="tabbable bne-tabs-framed tabs-above clearfix"> | |
<ul class="nav nav-tabs"> | |
<li class=""><a href="#tab_893" data-toggle="tab"> Tab Title #1</a></li> | |
<li class=""><a href="#my_tab2" data-toggle="tab"> Tab Title #2</a></li> | |
<li class=""><a href="#my_tab3" data-toggle="tab"> Tab Title #3</a></li> | |
</ul> | |
<div class="tab-content"> | |
<div id="tab_893" class="tab-pane fade clearfix">Tab 1 content….. Donec ullamcorper nulla non metus auctor fringilla. Aenean lacinia bibendum nulla sed consectetur. Sed posuere consectetur est at lobortis.</div> | |
<div id="my_tab2" class="tab-pane fade clearfix">Tab 2 content….. Donec ullamcorper nulla non metus auctor fringilla. Aenean lacinia bibendum nulla sed consectetur. Sed posuere consectetur est at lobortis.</div> | |
<div id="my_tab3" class="tab-pane fade clearfix">Tab 3content….. Donec ullamcorper nulla non metus auctor fringilla. Aenean lacinia bibendum nulla sed consectetur. Sed posuere consectetur est at lobortis. <a href="#my_tab2" data-toggle="tab" aria-expanded="false">Go back</a> to tab #2.</p></div> | |
</div> | |
</div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
brilliant