Image src Property - Return the URL of an image: - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Image

Description

Image src Property - Return the URL of an image:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

<img id="myImg" src="http://java2s.com/resources/a.png" width="107" height="98">

<button onclick="myFunction()">Test</button>

<script>
function myFunction() {/*from w  w w.j  a v a2  s.co  m*/
    var v = document.getElementById("myImg").src;
    console.log(v);
}
</script>

</body>
</html>

Related Tutorials