0
我的頁面中有多個嵌套的ul。通過以下jquery代碼顯示嵌套的ul。如何僅顯示當前li的孩子並隱藏其他li孩子
jQuery的
$("li").click(function(){
$(this).children("ul").show("slow");
});
但我想在同一時間只顯示一個嵌套的UL認證。我的意思是當我點擊一個li時,它應該只顯示它的子ul並隱藏其他子ul。我在我以前的jquery代碼中添加了以下行:
$("li ul").not(this).hide("slow");
但它不起作用。
CSS
li ul{
display:none;
}
HTML
<li>
<a href="#">Insert + </a>
<ul>
<li>
<a href="services.php">Services</a>
</li>
<li>
<a href="notice.php">Notice and Information</a>
</li>
</ul>
</li>
<li>
<a href="#">View + </a>
<ul>
<li>
<a href="services.php">Comments</a>
</li>
<li>
<a href="notice.php">Status</a>
</li>
</ul>
</li>
非常感謝@Amal –
很高興幫助你:) – Amal