Javascript examples for DOM HTML Element:Image
The Image object represents an HTML <img> element.
You can access an <img> element by using getElementById():
<!DOCTYPE html> <html> <body> <img id="myImg" src="http://java2s.com/resources/a.png" alt="alt message" width="304" height="200"> <button onclick="myFunction()">get the URL of the image</button> <p id="demo"></p> <script> function myFunction() {//from www . jav a 2 s . co m var x = document.getElementById("myImg").src; document.getElementById("demo").innerHTML = x; } </script> </body> </html>