How to know if a tab is enabled on jQuery tabs?

ⅰ亾dé卋堺 提交于 2019-12-19 09:22:12

问题


I can't find in the API of jQuery UI Tabs ( http://docs.jquery.com/UI/Tabs) a method to know if a certain tab is enabled or not, I need that because in an event of my application I want to enable a certain tab only if that tab is disabled.

Do you know how can I get that information from the jquery api?

Thanks in advance.


回答1:


The disabled option returns an aray of he indexes of the disabled tabs, so a function to check if one's disabled would look like this:

function isDisabled(index) {
  return $.inArray(index, $("#tabs").tabs("option", "disabled")) > -1;
}

You can give it a try here, this just uses $.inArray() to see if the index is present, just remember the index is 0 based, so the 1st tab is 0, 2nd one is 1, etc.




回答2:


You're almost there (it's on your link): disabled

//getter
var disabled = $( ".selector" ).tabs( "option", "disabled" );
//setter
$( ".selector" ).tabs( "option", "disabled", true );


来源:https://stackoverflow.com/questions/3625198/how-to-know-if-a-tab-is-enabled-on-jquery-tabs

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