Definition and Usage..
The images collection returns a collection of all img elements in the document.
Note: The elements in the collection are sorted as they appear in the source code.
Note: The images collection does not return a collection of input elements with type="image".
Syntax: document.images
CODING:The images collection returns a collection of all img elements in the document.
Note: The elements in the collection are sorted as they appear in the source code.
Note: The images collection does not return a collection of input elements with type="image".
Syntax: document.images
<!DOCTYPE html>
<html>
<body>
<img src="klematis.jpg" alt="flower" width="150" height="113">
<br><button onclick="SRC()">Image Source</button><br>
<img src="klematis2.jpg" alt="flower" width="152" height="128">
<br><button onclick="style1()">Change Style</button><br>
<img id="emojo" src="smiley.gif" alt="Smiley face" width="42" height="42">
<br><button onclick="size()">Change Size</button>
<p id="demo"></p>
<script>
function SRC() {
document.getElementById("demo").innerHTML = document.images[0].src;
}
function style1() {
document.images[1].style.border="5pt dashed lightgreen";
}
function size() {
document.images[2].width="60";
document.images[2].height="60";
}
</script>
</body>
</html>
<html>
<body>
<img src="klematis.jpg" alt="flower" width="150" height="113">
<br><button onclick="SRC()">Image Source</button><br>
<img src="klematis2.jpg" alt="flower" width="152" height="128">
<br><button onclick="style1()">Change Style</button><br>
<img id="emojo" src="smiley.gif" alt="Smiley face" width="42" height="42">
<br><button onclick="size()">Change Size</button>
<p id="demo"></p>
<script>
function SRC() {
document.getElementById("demo").innerHTML = document.images[0].src;
}
function style1() {
document.images[1].style.border="5pt dashed lightgreen";
}
function size() {
document.images[2].width="60";
document.images[2].height="60";
}
</script>
</body>
</html>
Comments
Post a Comment