Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

zh-cn: init the translation of Document.children #24177

Merged
merged 2 commits into from
Nov 4, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions files/zh-cn/web/api/document/children/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
---
title: "Document: children 属性"
short-title: children
slug: Web/API/Document/children
page-type: web-api-instance-property
browser-compat: api.Document.children
yin1999 marked this conversation as resolved.
Show resolved Hide resolved
yin1999 marked this conversation as resolved.
Show resolved Hide resolved
---

{{ APIRef("DOM") }}

只读的 **`children`** 属性返回一个实时的 {{domxref("HTMLCollection")}},其中包含对调用该属性的文档的所有子 {{domxref("Element", "元素")}}。
yin1999 marked this conversation as resolved.
Show resolved Hide resolved

对于 HTML 文档,这通常只有根 `<html>` 元素。

请参见 {{domxref("Element.children")}} 以获取文档中具体 HTML 元素的子元素。

## 值

一个 {{ domxref("HTMLCollection") }},它是当前文档子 DOM 元素的一个实时、有序集合。你可以通过对集合使用 {{domxref("HTMLCollection.item()", "item()")}} 方法,或者使用 JavaScript 数组风格的表示法来访问集合中的单个子节点。

如果文档没有元素子节点,则 `children` 是一个空列表,其 `length` 为 `0`。

## 示例

```js
document.children;
// HTMLCollection [<html>]
// 通常只包含根 <html> 元素,即文档唯一的直接子元素
```

请参见 {{domxref("Element.children")}} 以获取文档中具体 HTML 元素的子元素。

## 规范

{{Specifications}}

## 浏览器兼容性

{{Compat}}

## 另请参见
yin1999 marked this conversation as resolved.
Show resolved Hide resolved

- {{domxref("Element.children")}}
- {{domxref("Node.childNodes")}}
Loading