Having trouble deselecting all jquery tabs

*爱你&永不变心* 提交于 2019-12-10 16:03:41

问题


I set up some jQuery tabs to start off with no tabs selected like this:

$('#tabs').tabs( { selected: -1 } );  

Then I also have a separate link that when pressed needs to deselect all the tabs.

$("#deselectButton").click(function(){      
    $('#tabs').tabs( 'select' , -1 )
});

or

$("#deselectButton").click(function(){      
    $('#tabs').tabs( 'selected' , -1 )
});

The deselectButton click does deselect the tabs content, however the tabs title remains active with the class 'ui-tabs-selected ui-state-active'.

What is the correct way to deselect all the tabs?


回答1:


Try this code:

$("#deselectButton").click(function(){          
    $('#tabs').tabs( 'selected' , -1 )
    $(".ui-tabs-selected").removeClass("ui-state-active").removeClass("ui-tabs-selected");
});



回答2:


jQuery 1.10 requires the collapsible option to be set to true.

$('#tabs').tabs('option', 'collapsible', true);
$('#tabs').tabs( 'option', 'active', false );



回答3:


If you are using the jQuery UI version 1.9+ then the CSS code has changed to:

$('#tabs').tabs('option', 'active', false);

or:

$('.ui-tabs-active').removeClass('ui-tabs-active ui-state-active');

as per comments below. Thanks



来源:https://stackoverflow.com/questions/1438999/having-trouble-deselecting-all-jquery-tabs

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!