在选择的jQuery UI选项卡上显示/隐藏某个div [英] show/hide certain div on select of jQuery UI tabs

查看:204
本文介绍了在选择的jQuery UI选项卡上显示/隐藏某个div的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个工作的jQuery UI标签,结构类似这样:

I have a working jQuery UI tabs, the structure is similarly like this:

<script>
    $( "#tabs" ).tabs();
</script>

<div id="tabs">
  <ul>
    <li><a href="#tabs-1"></a>Tab 1</li>
    <li><a href="#tabs-2"></a>Tab 2</li>
  </ul>
  <div id="tabs-1">
    <!-- content of tab 1 -->
  </div>
  <div id="tabs-2">
    <!-- content of tab 2 -->
  </div>
</div>
<div id="extra">
    <!-- some contents here -->
</div>

现在,我想在选择 Tab 2 时隐藏div ,而在选择标签1 时显示。我不太明白jQuery UI标签上的事件。

Now, I wanted to hide the div extra when Tab 2 is selected, while showing it when Tab 1 is selected. I can't quite understand the event thing on jQuery UI tabs.

推荐答案

activate event

$("#tabs").tabs({
    activate: function (e, ui) {
        $('#extra').toggle(ui.newPanel.is('#tabs-1'))
    }
});

演示:小提琴

这篇关于在选择的jQuery UI选项卡上显示/隐藏某个div的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆