gpt4 book ai didi

JQuery 在类里面停止切换

转载 作者:行者123 更新时间:2023-12-01 06:59:50 26 4
gpt4 key购买 nike

我目前有无法更改的过滤器 div 类。我想要一个 .toggle,这样当单击一个部分时,其余部分将隐藏到下一类“.refinement_custom_category_section”。目前它几乎可以工作,它只是隐藏了该部分下方的所有内容,而我只想在单击时隐藏该部分。

  <div class="refinement_custom_category_section">Find by Condition</div>
<div class="refinement_filter"><a href="">New (52)</a></div>
<div class="refinement_filter"><a href="">Used (7)</a></div>
<div class="refinement_filter"><a href="">Overstock - New (2)</a></div>
<div class="refinement_custom_category_section">Find by Section</div>
<div class="refinement_filter"><a href="">1 Section (2)</a></div>
<div class="refinement_filter"><a href="">2 Section (40)</a></div>
<div class="refinement_filter"><a href="">3 Section (19)</a></div>
<div class="refinement_custom_category_section">Find by Door Type</div>
<div class="refinement_filter"><a href="">Solid Door (34)</a></div>
<div class="refinement_filter"><a href="">Glass Door, Sliding (6)</a></div>
<div class="refinement_filter"><a href="">Glass Door, Swing (21)</a></div>
<div class="refinement_custom_category_section">Find by Exterior</div>
<div class="refinement_filter"><a href="">Black (33)</a></div>
<div class="refinement_filter"><a href="">Stainless Steel (28)</a></div>
<div class="refinement_custom_category_section">Find by Height</div>
<div class="refinement_filter"><a href="">34.5 inches (12)</a></div>
<div class="refinement_filter"><a href="">35.625 inches (16)</a></div>
<div class="refinement_filter"><a href="">35.875 inches (11)</a></div>
<div class="refinement_filter"><a href="">37 inches (20)</a></div>
<div class="refinement_filter"><a href="">38.75 inches (2)</a></div>
</div>
<script>
$(".refinement_custom_category_section").click(function () {
$(this).nextAll("div.refinement_filter").toggle("fast");
});
</script>

最佳答案

您需要nextUntil() :

$(this).nextUntil("div.refinement_custom_category_section").toggle("fast");

nextAll 将选择与选择器匹配的所有同级。

关于JQuery 在类里面停止切换,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4971839/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com