how to create loop for dom element div ? i want to copy div 100 time

Viewed 16

how to loop div element ?? and where to put the loop , i want to copy div element 100 time in the page

let myMainElement = document.createElement("div");
let myHeading = document.createElement("h2");
let myPara = document.createElement("p");

let myHeadingText = document.createTextNode("Product Title");
let myParaText = document.createTextNode("Product Description");

// Add Heading Text
myHeading.appendChild(myHeadingText);

// Add Heading To Main Element 
myMainElement.appendChild(myHeading);

// Add text to Paragraph
myPara.appendChild(myParaText);

// Add Paragraph to MainEle
myMainElement.appendChild(myPara);


myMainElement.className = "product" ;

document.body.appendChild(myMainElement);

0 Answers
Related