我可以使用以下代码迭代所有选项卡
$('#tabs .ui-tabs-nav a').each(function() {
var id = $(this).attr('href');
}
(由 https://forum.jquery.com/topic/how-to-iterate-through-tabs 提供)
我可以使用以下代码检查选项卡是否通过其索引启用
function isDisabled(index) {
return $.inArray(index, $("#tabs").tabs("option", "disabled")) > -1;
}
(由 How to know if a tab is enabled on jQuery tabs? 的 Nick Craver 提供)
如何迭代所有已启用的选项卡?
最佳答案
您可以使用 $.filter
删除禁用的过滤器,然后使用 $.each
删除剩余的过滤器:
$('#tabs .ui-tabs-nav a').filter(function(index) {
return !isDisabled(index);
}).each(function() {
var id = $(this).attr('href');
});
或者你可以$.not
:
$('#tabs .ui-tabs-nav a').not(isDisabled).each(function() {
var id = $(this).attr('href');
});
关于javascript - 迭代 Jquery 中启用的选项卡,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32210281/