[转]Hide or Remove jquery ui tab based on condition

本文转自:http://*.com/questions/19132970/hide-or-remove-jquery-ui-tab-based-on-condition

问:

Html:

<div id="tabs">
<ul>
<li><a href="#tabs-1">Tab1</a></li>
<li><a href="#tabs-2">Tab2</a></li>
<li><a href="#tabs-3">Tab3</a></li>
</ul>
<div id="tabs-1">
Tab1 Contain
</div>
<div id="tabs-2">
Tab2 Contain
</div>
<div id="tabs-3">
tab3 contain
</div>
</div>

What I try on js :

var id="A";
$( "#tabs" ).tabs();
if(id==="A")
{
$( "#tabs-2" ).tabs( "option", "hide", { effect: "explode", duration: 1000 } );
//$('#ui-id-2').hide(); }

Sample Fiddle.

I want to hide or remove particular tab if condition is met.Thanks.

答:

Try

var id = "A";
$("#tabs").tabs();
if (id === "A") {
$('#tabs > ul li:has(a[href="#tabs-1"])').hide()
$("#tabs").tabs('refresh');
$("#tabs").tabs('option', 'active', 1);
}

Demo: Fiddle

上一篇:单独使用jdbc编程问题总结(一)


下一篇:Win7下搭建Go语言开发环境