Document images Collection - Add a black dotted border to the first <img> element in the document: - Javascript DOM

Javascript examples for DOM:Document images

Description

Document images Collection - Add a black dotted border to the first <img> element in the document:

Demo Code

ResultView the demo in separate window

<!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>

Related Tutorials