我试图用 j子制造一种习俗礼让,已经读过几个关于 st流的解决办法,但我似乎无法去做工作,我认为必须处理兄弟姐妹。 无论如何,这是我的《html法典》:
<div class="menu">
<ul>
<li class="current">
<a href="#" class="current"><img class="icon" src=""/>Dashboard</a>
</li>
<li>
<a href="#"><img class="icon" src=""/>Mail</a>
<ul class="submenu">
<li>
<a href="#" title="">Write New</a>
</li>
<li>
<a href="#" title="">Junk</a>
</li>
<li>
<a href="#" title="">Deleted</a>
</li>
</ul>
</li>
<li>
<a href="#"><img class="icon" src=""assets/colors.png""/>Child</a>
<ul class="submenu">
<li>
<a href="#">Child 1</a>
</li>
<li>
<a href="#">Child 2</a>
</li>
<li>
<a href="#">Child 3</a>
</li>
</ul>
</li>
<li>
<a href="#"><img class="icon" src=""/>Grid</a>
</li>
<li>
<a href="#"><img class="icon" src=""/>Class</a>
</li>
</ul>
</div>
And here is my jQuery code:
$( .menu ul li a ).click(function() {
$(this).next( .submenu ).siblings( li ).slideUp();
$(this).next( .submenu ).slideToggle();
});
The menu toggles open fine, but when I open one, the others won t close.
感谢你们的帮助!