如何在 JavaScript 中使用 document.images?
htmljavascriptprogramming scripts更新于 2026/1/13 15:08:17
使用 JavaScript 中的 document.images属性获取文档中的 <img> 标签数量。
示例
您可以尝试运行以下代码以在 JavaScript 中实现 document.images 属性。
<!DOCTYPE html>
<html>
<head>
<title>JavaScript 示例</title>
</head>
<body>
<h1>TutorialsPoint Tutorials</h1>
<img src="/javascript/images/javascript-mini-logo.jpg"/><br>
<img src="/html5/images/html5-mini-logo.jpg"/>
<script>
var num = document.images.length;
document.write("<br>How many images? "+num);
</script>
</body>
</html>
相关文章
有用资源
html 参考教程 - 该教程包含有关 html 的更多信息:https://www.cainiaomax.com/html/

