Last active
October 26, 2017 12:57
-
-
Save tallesairan/8d864dd9b6f8f21df502e5dea9253013 to your computer and use it in GitHub Desktop.
go to last tab after reload page bootstrap
This file contains 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
$(function() { | |
// for bootstrap 3 use 'shown.bs.tab', for bootstrap 2 use 'shown' in the next line | |
$('a[data-toggle="tab"]').on('shown.bs.tab', function (e) { | |
// save the latest tab; use cookies if you like 'em better: | |
localStorage.setItem('lastTab', $(this).attr('href')); | |
}); | |
// go to the latest tab, if it exists: | |
var lastTab = localStorage.getItem('lastTab'); | |
if (lastTab) { | |
$('[href="' + lastTab + '"]').tab('show'); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment