Im trying to create a grid based gallery where the code is dynamically generated. What I need to do is add a close a each time is has 4 child elements and then open a new one. My current logic looks like this but does not work.
var count = $(".gallery .row .col-md-3").length;
console.log(count);
if(count % 4 === 0 ) {
console.log('Hit 4');
$(".gallery-image").after("</div><div class='row'>");
}