Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR HTML

how to populate a grid with images in html

var imagePath="./image/seperate-";
var numberOfImage=100;

var parentDIV = document.getElementsByClassName("grid-container-parent")[0];

for(var i=0;i<numberOfImage;i++){
    var tempDIV= document.createElement('div');
    tempDIV.setAttribute('class','grid-container');
    var innerHTML= `<img src='`+(imagePath+i)+`.png'></img>`
    tempDIV.innerHTML=innerHTML;
    parentDIV.appendChild(tempDIV);
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #populate #grid #images #html
ADD COMMENT
Topic
Name
8+2 =