如何在新选项卡上清空未选中的ajax .tabs()

时间:2011-12-22 02:50:39

标签: jquery

我遇到了ajax .tabs()的问题,并清空或删除了未选中的标签内容。我搜索了jQuery网站并发现了这个事件,但对下一步是什么感到困惑:

$( ".selector" ).bind( "tabsselect", function(event, ui) {

   // All other tabs need to be empty when the new tab is selected
   // Before the selected tab is loaded (ajax)

});

任何人都可以帮忙吗?

1 个答案:

答案 0 :(得分:0)

使用适当的jQuery .empty()调用selector方法将其应用于所有标签:

$( ".selector" ).bind( "tabsselect", function(event, ui) {
   // All other tabs need to be empty when the new tab is selected
   // Before the selected tab is loaded (ajax)

   $("a selector for your tabs").empty();

   // ajax to populate the selected tab here
});

我已经说过“标签的选择器”,你只需要自己设置selector - 可能是“.selector”,从您展示的代码片段开始,但不会看到您的HTML我不知道。

(注意:清除包含刚刚选择的所有选项卡应该没问题,因为在这样做之后你将会重新填充刚刚选择的那个...)