JSFiddle - React, Tailwind, and code Playground
by Pedro3M
HTML
<div id="PeptubeContributors"></div>
JavaScript
var myarray = [];
var showOnly = 4, perRow = 4, showFiles = 3;
var count = 0;
var DisplayHtml = "";
myarray[0] = "a";
myarray[1] = "b";
myarray[2] = "c";
myarray[3] = "d";
myarray[4] = "e";
myarray[5] = "f";
var isRowOpen = false;
$.each(myarray, function( index, value ) {
if(count < showOnly){
//alert(count+"%"+perRow+"="+count%perRow);
if (count == 0 || count % perRow == 0) { DisplayHtml += "<div class=\"row\">"; isRowOpen = true; }
DisplayHtml += "<p>"+ value +"</p>";
count++;
if (count % perRow == 0) { DisplayHtml += "</div>"; isRowOpen = false; }
} else {
return false;
}
});
if(isRowOpen) { DisplayHtml += "</div>"; isRowOpen = false; }
alert(DisplayHtml);
$("#PeptubeContributors").append(DisplayHtml);