JSFiddle - React, Tailwind, and code Playground

CSS

div {
    width: 450px;
    height: 400px;
    background-color: #ccc;
    overflow: auto;
}
span {
    display: inline-block;
    width: 50px;
    height: 50px;
    background-color: #777;
    margin: 0 30px 30px 0;
}

JavaScript

$(function() {
    var wrapper = $("<div></div>")
    
    for (i = 0; i < 100; i++) {
        wrapper.append("<span></span>");
    }
            
    $("body").append(wrapper);
    
    color_rows();
});

function color_rows() {
    $("span").each(function(i) {
        if (i % 10 >= 5) {
            $(this).css("background-color", "red");
        }
    });
}