Javascript examples for DOM HTML Element:Image
Adding another image by setting src attribute
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript"> function doImgSwap(el)//from ww w . j av a2 s . co m { var img = document.createElement('img'); img.setAttribute('src','http://www.java2s.com/style/download.png'); el.appendChild(img); } </script> </head> <body> <p> <a href="#" id="newImg" onclick="doImgSwap(this)"> <img src="van.png"> </a> </p> </body> </html>