小白教程
所有教程
关于
Search
172.70.131.107
172.70.131.107
参数设置
贡献
退出
操作
编辑
移动
保护
信息
历史
删除
查看“Coll doc images”的源代码
本页内容
上一节:
Met_document_getelementsbytagname
下一节:
Prop_document_implementation
因为以下原因,您没有权限编辑本页:
您请求的操作仅限属于该用户组的用户执行:
用户
您可以查看和复制此页面的源代码。
{{DISPLAYTITLE:document.images}}[[Category:dom obj document|25]] = HTML DOM images 集合 = [[dom obj document|Document 对象]] == 定义和用法 == images 集合返回当前文档中所有图片的数组。 == 语法 == <pre> document.images[].property </pre> == 浏览器支持 == 所有主要浏览器都支持 images 集合 == 实例 1 == 返回文档的图片数: <sample title="" desc="" lang="html" hererun="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> </sample> 以上实例输出结果: <sample title="" desc="" lang="html" hererun="1"> 图像数目: 2 </sample> <run name=""> <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>小白教程(xiaobai.wang)</title> </head> <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> </run> == 实例 2 == 返回文档中的第一张图片: <sample title="" desc="" lang="html" hererun="1"> <html> <body> <img id="xiaobai1" border="0" src="klematis.jpg" width="150" height="113"> <img id="xiaobai2" border="0" src="klematis2.jpg" width="152" height="128"> <p>第一个图像的ID: <script> document.write(document.images[0].id); </script></p> </body> </html> </sample> 以上实例输出结果: <sample title="" desc="" lang="html" hererun="1"> 第一个图像的ID:xiaobai1 </sample> <run name=""> <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>小白教程(xiaobai.wang)</title> </head> <body> <img id="xiaobai1" border="0" src="klematis.jpg" width="150" height="113"> <img id="xiaobai2" border="0" src="klematis2.jpg" width="152" height="128"> <p>第一个图像的ID: <script> document.write(document.images[0].id); </script></p> </body> </html> </run> [[dom obj document|Document 对象]]
返回至“
Coll doc images
”。
上一节:
Met_document_getelementsbytagname
下一节:
Prop_document_implementation