Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save barbwiredmedia/6344371 to your computer and use it in GitHub Desktop.
Save barbwiredmedia/6344371 to your computer and use it in GitHub Desktop.
jQuery - Twitter Bootstrap's Tab piece. This allows hotlinking to the tab (opens page, and opens tab specified in the url) as well as changes url on tab change. (Should keep the nav-tabs class the same.)
<script>
$(function(){
var hash = window.location.hash;
hash && $('ul.nav a[href="' + hash + '"]').tab('show');
$('.nav-tabs a').click(function (e) {
$(this).tab('show');
var scrollmem = $('body').scrollTop();
window.location.hash = this.hash;
$('html,body').scrollTop(scrollmem);
});
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment