How to check if a tab is clicked?

my question is simple.

I have 2 tabs and I want to warn the tab I'm going to select

$( '#social_edit_pannels' ).tabs({ select: function(event, ui) { var firstSelect = $('#tabs').tabs('option', 'selected'); alert(firstSelect); if (firstSelect == 0) { alert("0"); } else if (firstSelect == 1) { alert("1"); } } }); 

so that this example checks for an already pressed tab.

any ideas?

+4
source share
1 answer

It looks like you want to know which tab was selected, but using the method that you have, was selected earlier.

Just call ui.index if you want the item to be under ui.tab

 $('#social_edit_pannels').tabs({ select: function(event, ui) { var theSelectedTab = ui.index; if (theSelectedTab == 0) { alert("0"); } else if (theSelectedTab == 1) { alert("1"); } } }); 

jsfiddle sample code.

+4
source

Source: https://habr.com/ru/post/1345166/


All Articles