我有下面的html代码,想要更改
内联样式
显示:块
至
显示:无
其中等级是ln-b到ln-z
<div class="filter-div ln-b" style="display: block;"></div>
<div class="filter-div ln-c" style="display: block;"></div>
<div class="filter-div ln-d" style="display: block;"></div>
<div class="filter-div ln-e" style="display: block;"></div>
<div class="filter-div ln-f" style="display: block;"></div>
<div class="filter-div ln-g" style="display: block;"></div>
<div class="filter-div ln-h" style="display: block;"></div>
<div class="filter-div ln-i" style="display: block;"></div>
<div class="filter-div ln-j" style="display: block;"></div>
<div class="filter-div ln-k" style="display: block;"></div>
<div class="filter-div ln-l" style="display: block;"></div>
<div class="filter-div ln-m" style="display: block;"></div>
<div class="filter-div ln-n" style="display: block;"></div>
<div class="filter-div ln-o" style="display: block;"></div>
<div class="filter-div ln-p" style="display: block;"></div>
<div class="filter-div ln-q" style="display: block;"></div>
<div class="filter-div ln-r" style="display: block;"></div>
<div class="filter-div ln-s" style="display: block;"></div>
<div class="filter-div ln-t" style="display: block;"></div>
<div class="filter-div ln-u" style="display: block;"></div>
<div class="filter-div ln-v" style="display: block;"></div>
<div class="filter-div ln-w" style="display: block;"></div>
<div class="filter-div ln-x" style="display: block;"></div>
<div class="filter-div ln-y" style="display: block;"></div>
<div class="filter-div ln-z" style="display: block;"></div>
有什么想法或建议吗?谢谢。
最佳答案
我建议(假设它们以该顺序出现并且是兄弟姐妹),并且还有一个.filter-div.ln-a
元素,您不想隐藏它:
$('.filter-div.ln-b').nextUntil($('.ln-z').next()).addBack().css('display','none');
JS Fiddle demo。
参考文献:
addBack()
。css()
。next()
。nextUntil()
。关于javascript - jQuery更改多个div元素的内联样式,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/18786348/