Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save Farmatique/1c02a108c0abd5ed3632ccfc03eba3aa to your computer and use it in GitHub Desktop.
Save Farmatique/1c02a108c0abd5ed3632ccfc03eba3aa to your computer and use it in GitHub Desktop.
Bootstrap Go to Tab by url hash
//https://stackoverflow.com/questions/7862233/twitter-bootstrap-tabs-go-to-specific-tab-on-page-reload-or-hyperlink
// Javascript to enable link to tab
var url = document.location.toString();
if (url.match('#')) {
jQuery('.nav-tabs a[href="#' + url.split('#')[1] + '"]').tab('show');
}
// Change hash for page-reload
jQuery('.nav-tabs a').on('shown.bs.tab', function (e) {
window.location.hash = e.target.hash;
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment