Image Objects

 <html>

<body>

<img id="myImg" src="img_pulpit.jpg" alt="The Pulpit Rock" width="304" height="228">

<button onclick="myFunction()">Try it</button>

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

<script>

function myFunction() {

  var x = document.getElementById("myImg").alt;

  document.getElementById("demo").innerHTML = x;

}

</script>

</body>

</html>


Comments

Popular posts from this blog

Important Questions for XII

Sample Question Bank Grade 12

Question Collection-11