HTML DOM images 集合

定义和用法
images 集合返回当前文档中所有图片的数组。
语法
document.images[].property
浏览器支持
所有主要浏览器都支持 images 集合
实例
返回文档的图片数:
<img border="0" src="/examples/klematis.jpg" width="150" height="113"> <img border="0" src="/examples/klematis2.jpg" width="152" height="128"> <p>图像数目: <script> document.write(document.images.length); </script> </p>
返回文档中的第一张图片:
<img id="mifengjc1" border="0" src="/examples/klematis.jpg" width="150" height="113"> <img id="mifengjc2" border="0" src="/examples/klematis2.jpg" width="152" height="128"> <p>第一个图像的ID: <script> document.write(document.images[0].id); </script> </p>
