Get Input Image Field - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Input Image

Introduction

The Input Image object represents an HTML <input> element with type="image".

You can access an <input> element with type="image" by using getElementById():

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

<input type="image" src='http://java2s.com/resources/a.png' id="myImage" >

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

<p id="demo"></p>

<script>
function myFunction() {//  ww w  .  ja v  a2  s.co m
    var x = document.getElementById("myImage").src;
    document.getElementById("demo").innerHTML = x;
}
</script>
</body>
</html>

Related Tutorials