代码示例:(标识:jsck_htmlcollection_1)
<!DOCTYPE html>
<html>
<body>

<h1>HTMLCollection 对象</h1>

<p>使用 getElementsByTagName() 方法来返回 HTMLCollection:</p>

<script>
var x = document.getElementsByTagName("P");
document.write(x);
</script>

</body>
</html>
运行结果: