Created
December 10, 2017 09:49
-
-
Save Scordavis/6a47cb80b30d248e49622b3a594ef743 to your computer and use it in GitHub Desktop.
Переключение вкладки tab в Bootstrap при переходе с внешней ссылки (другой страницы). Switch tab on Bootstrap tabs by clicking on externa
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