[Solved] Give all elements in Class an seperate Id Javascript


Just add attribute id using, addImage.id="Image"+i; or setAttribute('id', "Image"+i) like the following:

for(var i=0;i<Images.length;i++){
   var addImage = document.createElement("img"); 
   addImage.className = "cssImages"; 
   addImage.setAttribute('src', Images[i]); 
   addImage.setAttribute('id', "Image"+i);
   IMGdiv.appendChild(addImage);
}

4

solved Give all elements in Class an seperate Id Javascript