Monday 2 December 2019

javascript - display array of images using getelementbyid in js

Using document.createElement and appendChild, you might do:



var myContainer = document.getElementById("someContainerId");


for (i=0;i var myimg = document.createElement("img");
myimg.src= tar[i];
myimg.width="100";
myimg.height="100";

myContainer.appendChild(myimg);
}



Make sure, of course, that there really is a container element with the id of someContainerId, or whatever id you want to give it. It might be best if the container element were a

.

No comments:

Post a Comment

php - file_get_contents shows unexpected output while reading a file

I want to output an inline jpg image as a base64 encoded string, however when I do this : $contents = file_get_contents($filename); print &q...