I'm working on dynamically generating a grid of divs with a specific size using the code below:
function createGrid(gridSize) {
var container = document.getElementById('container');
for (var i = 0; i < gridSize; i++) {
var row = document.createElement("div");
row.className = "row";
for(var j = 0; j < gridSize; j++) {
var cell = document.createElement("div");
cell.className = "cell";
$('.cell').css("width", (960 / gridSize));
$('.cell').css("height", (960 / gridSize));
row.appendChild(cell);
}
container.appendChild(row);
}
}
After calling the createGrid function with a parameter of 4, I noticed that it generates a 3x4 grid instead of the intended 4x4 grid. Any ideas on what might be causing this issue?