Javascript examples for DOM:Document images
Document images Collection - Add a black dotted border to the first <img> element in the document:
<!DOCTYPE html> <html> <body> <img src="http://java2s.com/resources/a.png" alt="flower" width="150" height="113"> <img src="http://java2s.com/resources/b.png" alt="flower" width="152" height="128"> <img id="myImg" src="http://java2s.com/resources/c.png" alt="Smiley face" width="42" height="42"> <button onclick="myFunction()">Test</button> <p id="demo"></p> <script> function myFunction() {//from www.j a v a 2 s. co m var x = document.images[0]; x.style.border = "10px dotted black"; } </script> </body> </html>