我正在使用点击打开手风琴式脚本。问题是应用它的选择器是重复的,因此在单击链接时,只有被单击元素的子元素会受到影响,而所有其他列表项(重复的)在同时。
jquery是这样的:
$(document).ready(function(){
$("#odd-accordion ul.nextslide > li a").click(function(){
$("ul.nextslide-second a").slideToggle('300');
});
});
html是这样的:
<div class="adminmenuback">
<div class="commonlogo">
<img src="images/logo.png" alt="Wish2book">
</div>
<div class="searchh">
<input type="text" placeholder="search"><span class="menutitle_rightimage"></span>
</div>
<h2 class="menutitle"><span class="dashboard-icon"></span>Dashboard</h2>
<ul class="adminmenu" id="odd-accordion">
<li>
<h3><a href="#">Flights</a></h3>
<ul class="nextslide">
<li><a href="#">abc</a>
<ul class="nextslide-second">
<li><a href="#">abc-child</a>
</li>
</ul>
</li>
</ul>
</li>
<li>
<h3><a href="#">Flights</a></h3>
<ul class="nextslide">
<li><a href="#">abc</a>
<ul class="nextslide-second">
<li><a href="#">abc-child</a>
</li>
</ul>
</li>
</ul>
</li>
<li>
<h3><a href="#">Flights</a></h3>
<ul class="nextslide">
<li><a href="#">abc</a>
<ul class="nextslide-second">
<li><a href="#">abc-child</a>
</li>
</ul>
</li>
</ul>
</li>
</ul>
</div>
请帮忙。jsfiddle 链接在这里:http: //jsfiddle.net/BVz97/
在 jsfiddle 中,只需单击“abc”,所有 abc-child 都会被选中