Skip to content

Instantly share code, notes, and snippets.

@digamber89
Last active November 5, 2018 15:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save digamber89/00f7b053ef0beb71e443fe62948f19ae to your computer and use it in GitHub Desktop.
Save digamber89/00f7b053ef0beb71e443fe62948f19ae to your computer and use it in GitHub Desktop.
Bootstrap 3 Remember State
// store the currently selected tab in the hash value
$("ul.nav.panel-tabs > li > a").on("shown.bs.tab", function(e) {
var id = $(e.target).attr("href").substr(1);
window.location.hash = id;
});
// on load of the page: switch to the currently selected tab
var hash = window.location.hash;
$('ul.nav.panel-tabs a[href="' + hash + '"]').tab('show');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment