如何使用 jquery 禁用选项卡

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2629939/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-26 13:54:41  来源:igfitidea点击:

how to disable the tabs using jquery

jquery

提问by kumar

I have three subtabs under main tab, when I click main tab defauly I am displyaing tab1 data using jquery grid, now initially I need disable the tab2 and tab3. how?

我在主选项卡下有三个子选项卡,当我默认单击主选项卡时,我正在使用 jquery 网格显示 tab1 数据,现在最初我需要禁用 tab2 和 tab3。如何?

回答by tvanfosson

From the jQuery UI tabs documentation. Note that it's zero-based so this disables the 2nd and 3rd tabs.

来自 jQuery UI 选项卡文档。请注意,它是从零开始的,因此这将禁用第二个和第三个选项卡。

$( ".selector" ).tabs( { disabled: [1, 2] } );

回答by Justin Ethier

Assuming you are using the jQuery UI tabs:

假设您正在使用 jQuery UI 选项卡:

You can use "disable"to disable a given tab after initialization:

您可以使用"disable"在初始化后禁用给定的选项卡:

jQuery("#myTab").tabs( "disable" , index )

Alternatively, if you need to disable tabs when the tabs are first displayed, you can pass the disabledoption and an array of tabs to disable:

或者,如果您需要在第一次显示选项卡时禁用选项卡,您可以传递disabled选项和选项卡数组以禁用:

$( ".selector" ).tabs( { disabled: [1, 2] } );