Latest web development tutorials

HTML DOM 이미지 모음

문서 객체 참조 문서 객체

정의 및 사용

이미지 수집은 현재 문서에있는 모든 사진의 배열을 돌려줍니다.

문법

document.images[].property


브라우저 지원

Internet ExplorerFirefoxOperaGoogle ChromeSafari

모든 주요 브라우저는 이미지 수집을 지원


예 1

사진의 문서 번호로 돌아 가기 :

<html>
<body>

<img border="0" src="klematis.jpg" width="150" height="113">
<img border="0" src="klematis2.jpg" width="152" height="128">

<p>图像数目:
<script>
document.write(document.images.length);
</script></p>

</body>
</html>

위의 출력의 예 :

图像数目: 2

»시도

예 2

문서의 첫 번째 사진은 반환 :

<html>
<body>

<img id="w3big1" border="0" src="klematis.jpg" width="150" height="113">
<img id="w3big2" border="0" src="klematis2.jpg" width="152" height="128">

<p>第一个图像的ID:
<script>
document.write(document.images[0].id);
</script></p>

</body>
</html>

위의 출력의 예 :

第一个图像的ID:w3big1

»시도


문서 객체 참조 문서 객체