我想在标签上标记并打开2个div。像:
<div id="tabs">
<ul>
<li class="tab1"><a href="#tab1">tab1</a></li>
<li class="tab2"><a href="#tab2">tab2</a></li>
</ul>
<div id="tab1">this is tab1</div>
<div id="tab2">this is tab2</div>
<div id="tab3">this is tab3</div>
</div>
如果我想点击tab1标签,它会显示'this is tab1'和'this is tab3'。我怎样才能实现?欢呼声。
答案 0 :(得分:0)
试试这个:
<div id="tabs">
<ul>
<li class="tab1"><a href="#tab1">tab1</a></li>
<li class="tab2"><a href="#tab2">tab2</a></li>
</ul>
<div id="tab1">this is tab1</div>
<div id="tab2">this is tab2</div>
</div>
<!-- tab3 is outside of tabs and initially hidden -->
<div id="tab3" style="display:none;">this is tab3</div>
<script>
$(".tabs").tabs({activate: function() {
/* if tab1 activated then show tab3 */
if ($(".tabs").tabs("options","active") == 0 /* tab1 */) {
$(".div3").show();
} else {
$(".div3").hide();
}
}});
</script>
答案 1 :(得分:0)
对Sergey的解决方案进行细微更新,param应该是选项,而不是选项,请参阅http://api.jqueryui.com/tabs/