I have something like this generated by a procedure:
<div class="w-row">
<div class="w-col w-col-4 entry abc"> ... </div>
<div class="w-col w-col-4 entry abc def"> ... </div>
<div class="w-col w-col-4 entry def"> ... </div>
<div class="w-col w-col-4 entry 123"> ... </div>
</div>
To keep it correct however, I would like to wrap every 3 columns with a div with the class "w-row".
My output should be something like:
<div class="w-row">
<div class="w-col w-col-4 entry abc"> ... </div>
<div class="w-col w-col-4 entry abc def"> ... </div>
<div class="w-col w-col-4 entry def"> ... </div>
</div>
<div class="w-row">
<div class="w-col w-col-4 entry 123"> ... </div>
</div>
So, this is a galery plugin, so the number of elements may change after clicking on a filter. To display it, i have small function, as you can see here:
// show only divs, which has the current filter in its classes
$('.entry').each(function() {
if (!$(this).hasClass(filtername)) {
$(this).fadeOut();
} else {
$(this).fadeIn();
}
});
I tried to add a counter-variable cnt
and "wrap" every 3 items with a div, but that didn't work. Also i tried to add HTML (just a simple ) but for some reason i was overriding everything (guess because i used $.html();
Thanks for any advices