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
Post a Comment