I am using a for loop to dynamically add div
elements to a parent node in JavaScript, but I am unable to do because it adds only one element.
My code is this:
var row = document.getElementById("rowel");
var col = document.createElement('div');
col.className = "col-sm-3 col-md-3 col-lg-3 mr-auto";
var card = document.createElement('img');
card.src = "./assets/building.jpg";
card.style["max-width"] = "350px";
card.alt = "cant displayed";
col.appendChild(card);
for (let index = 0; index < 5; index++) {
row.appendChild(col);
}
Can some please help me to solve this?