Jquery UI禁用动态选项卡

Jquery UI disable dynamic tabs

本文关键字:选项 动态 UI Jquery      更新时间:2023-09-26

我的UI选项卡可以根据用户操作进行更改(例如,选项卡[0]中可能会出现状态消息)。

我还需要能够禁用特定的选项卡-我知道href,但索引很可能会更改。

UI dox说你可以传递href而不是索引,但我似乎无法实现。

这就是我正在做的:

var disableSlots = [];
$('ul.ui-tabs-nav li').each(function(index, el){
    if ($(this).children('a').attr('href') == '#DISABLE_ME'){
        disableSlots.push(index);
    }
});
$('#tabs').tabs("option","disabled",disableSlots);

有更好的方法吗?

您可以使用这种方法:

var index = $('#tabs a[href="#DISABLE_ME"]').parent().index();
$('#tabs').tabs("option", "disabled", index);