Created
August 21, 2020 08:00
-
-
Save MarioBinder/b975a45fe323fba4f00112214fbd8a1b to your computer and use it in GitHub Desktop.
bootstrap 4 - save active tab
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
$('a[data-toggle="tab"]').on('show.bs.tab', function(e) { | |
localStorage.setItem('activeTab', $(e.target).attr('href')); | |
}); | |
var activeTab = localStorage.getItem('activeTab'); | |
if(activeTab){ | |
$('#myTab a[href="' + activeTab + '"]').tab('show'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
via https://www.tutorialrepublic.com/faq/how-to-keep-the-current-tab-active-on-page-reload-in-bootstrap.php#:~:text=Answer%3A%20Use%20the%20HTML5%20localStorage,tab%20selected%20on%20page%20reload.