Created
July 7, 2015 08:10
-
-
Save umanda/ba0c31a928c83d287e51 to your computer and use it in GitHub Desktop.
Twitter Bootstrap Tabs: Go to Specific Tab on Page Reload or Hyperlink
This file contains hidden or 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
// Javascript to enable link to tab | |
var url = document.location.toString(); | |
if (url.match('#')) { | |
$('.nav-tabs a[href=#'+url.split('#')[1]+']').tab('show') ; | |
} | |
// Change hash for page-reload | |
$('.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