I'm trying to achieve that after every third item it should break loop and save index of loop from where it bring out and again start loop from next saved index and again break out after third iteration and continues till the end. HTML Markup is:
<div class="homepage-resources">
<div class="resource-col">
<a href="#">
<div class="blog-post-image">
<img src="xyz/image.png" />
</div>
</a>
</div>
<div class="resource-col">
<a href="#">
<div class="blog-post-image">
<img src="xyz/image.png" />
</div>
</a>
</div>
</div>
this resource-col is repeating many times, following is my jquery code:
jQuery(".homepage-resources").each(function() {
var tallestHeight = 0;
jQuery(this).find(".resource-col").each(function(i) {
if (i % 3 == 0 && i != 0) {
var imgHeight = jQuery(this).find(".blog-post-image > img").outerHeight();
if (imgHeight > tallestHeight ) {
tallestHeight = imgHeight;
}
jQuery(this).find(".blog-post-image").css("height", tallestHeight);
}
});
});
All I want is that to apply the same tallest height from to three items by comparing every three items, then break loop and go to next three items. I've tried this with modulus operator but not getting rest. It would be great if anyone can help to resolve this issue. Thanks in advance.