get last clicked tab index in jquery ui tab
I am using JQuery UI tabs , to get the current selected tab i am using ui.index but i want an index of last clicked tab.
for example, initially tab 1 is loaded after that if i click t开发者_如何学Pythonab 3 then in show method i can fetch tab 1's index and the same way if i click on tab 1 then i can fetch tab 3's index.
Why not just set a prevTab variable that is accessed during the show method and then reset to be the current tab?
var prevTab = 0;
$('#tabs').tabs({
show: function(event, ui) {
alert(prevTab); //do something with previous tab index
prevTab = ui.index; //set the new previous tab index to the current index
}
});
You could also set a cookie with the previous tab index.
精彩评论