您好我在两个嵌套的ul上使用jQuery幻灯片切换,但是当我点击辅助ul时,其他ul不会向上滑动。
如何让jQuery检测到正确的jQuery并将其向上滑动?
我有jsFiddle作为我正在做的事情的一个例子。关于我能做些什么不同的任何建议?
代码示例:
<ul class="top-category four columns">
<li class="filter-title">Filter by: Blog Categories <span class="icon-arrow-down3"></span>
<ul class="child-category">
<li class="filter-item">
<input type="checkbox" id="tag_278" name="blog_categories[]" class="fintech siteset-checkbox" value="FinTech" data-name="FinTech">FinTech</li>
</ul>
</li>
</ul>
<ul class="top-category four columns">
<li class="filter-title">Filter by: Staff <span class="icon-arrow-down3"></span>
<ul class="child-category">
<li class="filter-item">
<input type="checkbox" id="tag_283" name="staff[]" class="jan_stannard siteset-checkbox" value="Jan Stannard" data-name="Jan Stannard">Jan Stannard</li>
</ul>
</li>
</ul>
jquery
$( ".filter-title" ).click(function() {
$(this).children().nextAll('.child-category').slideToggle();
});
CSS
.child-category {display:none}
答案 0 :(得分:1)
试试这个:
$( ".filter-title" ).click(function() {
var child = $(this).children('.child-category') ,
rest = $('.child-category:visible').not(child);
child.slideToggle(); //toggle current one
rest.slideUp(); //close the rest
});
答案 1 :(得分:0)
试试这个:
$(".filter-title").click(function () {
$('.child-category:visible').stop(true, true).slideToggle(); // <---add this line
$(this).find('.child-category').stop(true, true).slideToggle();
});