Answer the question
In order to leave comments, you need to log in
How to filter when elements are in different blocks?
help me make such a filtering, I've been racking my brain all day, I can't figure out how to do this at all,
there is, let's say, this markup:
<ul>
<li></li>
<li class="hidden"></li>
<li class="hidden"></li>
<li></li>
</ul>
<ul>
<li></li>
<li></li>
<li class="hidden"></li>
<li></li>
</ul>
<ul>
<li></li>
<li class="hidden"></li>
<li class="hidden"></li>
<li></li>
<li></li>
<li></li>
</ul>
<ul>
<li class="hidden"></li>
<li></li>
</ul>
Answer the question
In order to leave comments, you need to log in
var lis = $('li').filter(':not(hidden)');
var uls = $('ul');
for (var i=0; i < lis.length; i++) {
$(lis[i]).appendTo(uls[~~(i/4)]);
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question