Javascript examples for DOM HTML Element:Image
Image alt Property - Change the alternate text of an image:
<!DOCTYPE html> <html> <body> <img id="myImg" src="http://java2s.com/resources/a.png" alt="alt message" width="107" height="98"> <button onclick="myFunction()">Test</button> <p id="demo"></p> <script> function myFunction() {/*from w w w .ja va2 s .c om*/ document.getElementById("myImg").alt = "newAlternateText"; document.getElementById("demo").innerHTML = "changed from 'alt message' to 'newAlternateText'"; } </script> </body> </html>