Answers for "how to insert image in javascript code"

3

how to insert image in javascript code

function add_img() { 
	var img = document.createElement('img'); 
    img.src = 'https://media.geeksforgeeks.org/wp-content/uploads/20190529122828/bs21.png'; 
	document.getElementById('body').appendChild(img);
}
Posted by: Guest on October-24-2020
0

how to insert image in javascript code

<div id="x"></div>

<script>
var img = document.createElement("img");
 
img.src = "image.png";
var src = document.getElementById("x");
 
src.appendChild(img);
</script>
Posted by: Guest on May-15-2020

Code answers related to "how to insert image in javascript code"

Code answers related to "Javascript"

Browse Popular Code Answers by Language