Created
May 21, 2018 06:06
-
-
Save fercreek/0fb649beaf216a9552e00335641d1fae to your computer and use it in GitHub Desktop.
JS: Add Hash for Bootstrap tab
http://stackoverflow.com/questions/12131273/twitter-bootstrap-tabs-url-doesnt-change
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
$(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); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment