Skip to content

Instantly share code, notes, and snippets.

@milon
Created December 1, 2016 07:25
Show Gist options
  • Select an option

  • Save milon/6ae8115219e0589b3fd2599c7a11dd5a to your computer and use it in GitHub Desktop.

Select an option

Save milon/6ae8115219e0589b3fd2599c7a11dd5a to your computer and use it in GitHub Desktop.
This will add the tab's id appended to url as hash link, so that you can bookmark the tab.
var url = document.URL;
var hash = url.substring(url.indexOf('#'));
$(".nav-tabs").find("li a").each(function(key, val) {
if (hash == $(val).attr('href')) {
$(val).click();
}
$(val).click(function(ky, vl) {
location.hash = $(this).attr('href');
});
});
@nesrineAmamou94
Copy link
Copy Markdown

works perfectly thank you !

@newnamator
Copy link
Copy Markdown

Excellent. This worked great. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment