如何在jquery中通过选项卡名称获取选项卡索引?
我需要通过此命令删除某个选项卡:
$(tabContainer).tabs('删除', 索引);
索引必须包含要关闭的选项卡的正确顺序。问题是,我以编程方式生成选项卡,因此很可能有错误的索引。
最佳答案
我认为这就是您想要的(“名称”是您的选项卡的名称):
// close tab with a given name
function removeTab(name) {
var tab = $('#tabs a').filter(function(){
return $(this).text() == name;
}).parent();
var index = $( "li", $tabs ).index(tab);
if (index>=0) {
$tabs.tabs( "remove", index );
}
}
关于jquery - 如何在jquery中通过选项卡名称获取选项卡索引?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1553099/