Adding an img element to a div with javascript

document.getElementById("placehere").appendChild(elem);

not

document.getElementById("placehere").appendChild("elem");

and use the below to set the source

elem.src="https://stackoverflow.com/questions/7802744/images/hydrangeas.jpg";

Leave a Comment