开发者

How to check if a tab is clicked?

my question is simple.

i have 2 ta开发者_开发技巧bs and i want to alert the tab that i am gonna 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");
        }
    }
});

just that this example checks the for the tab that is already clicked..

any ideas?


It sounds like you want to find out which tab was just selected, however using the method you have gets the tab that was selected previously.

Just call ui.index, if you want the element it is 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");
        }
    }
});

code example on jsfiddle.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜