1function add_img() {
2 var img = document.createElement('img');
3 img.src = 'https://media.geeksforgeeks.org/wp-content/uploads/20190529122828/bs21.png';
4 document.getElementById('body').appendChild(img);
5}
1<div id="x"></div>
2
3<script>
4var img = document.createElement("img");
5
6img.src = "image.png";
7var src = document.getElementById("x");
8
9src.appendChild(img);
10</script>