代码示例:(标识:jsck_element_children_1)
<!DOCTYPE html>
<html>
<body>
<h1>Element 对象</h1>

<h2>children 属性</h2>

<p>body 的子元素的标签名是:</p>

<p id="demo"></p>

<script>
const collection = document.body.children;
let text = "";
for (let i = 0; i < collection.length; i++) {
  text += collection[i].tagName + "<br>";
}
document.getElementById("demo").innerHTML = text;
</script>

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