Skip to content

Instantly share code, notes, and snippets.

@opposite-bracket
Created December 15, 2013 01:03
Show Gist options
  • Save opposite-bracket/7967303 to your computer and use it in GitHub Desktop.
Save opposite-bracket/7967303 to your computer and use it in GitHub Desktop.
Persistent Tabs with Twitter Bootstrap 3.0.0
$(document).ready(function () {
$('.nav-tabs a').click(function(e) {
e.preventDefault()
var hash = $(e.target).attr("href");
if (hash.substr(0,1) == "#") {
location.replace("#" + hash.substr(1));
}
$(this).tab('show');
});
if(location.hash.substr(0,1) == "#") {
$("a[href='" + location.hash + "']").tab("show");
}else{
$($('.nav-tabs a')[0]).tab("show");
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment