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: update the translation of NodeList.values() #23299

Merged
merged 1 commit into from
Aug 30, 2024
Merged
Changes from all commits
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
41 changes: 22 additions & 19 deletions files/zh-cn/web/api/nodelist/values/index.md
Original file line number Diff line number Diff line change
@@ -1,55 +1,58 @@
---
title: NodeList.values()
title: NodeListvalues() 方法
slug: Web/API/NodeList/values
l10n:
sourceCommit: 312081aabba3885b35a81107b3c2fc53428896c5
---

{{APIRef("DOM")}}

该方法返回一个 iterator 迭代器,可以利用迭代器遍历所有 value
**`NodeList.values()`** 方法返回一个用于遍历该对象中包含的所有值(值为 {{domxref("Node")}} 对象)的{{jsxref("Iteration_protocols","迭代器", "", 1)}}

## Syntax
## 语法

```
nodeList.values();
```js-nolint
values()
```

### Return value
### 返回值

Returns an {{jsxref("Iteration_protocols","iterator")}}.
返回一个{{jsxref("Iteration_protocols","迭代器", "", 1)}}

## Example
## 示例

```js
var node = document.createElement("div");
var kid1 = document.createElement("p");
var kid2 = document.createTextNode("hey");
var kid3 = document.createElement("span");
const node = document.createElement("div");
const kid1 = document.createElement("p");
const kid2 = document.createTextNode("hey");
const kid3 = document.createElement("span");

node.appendChild(kid1);
node.appendChild(kid2);
node.appendChild(kid3);

var list = node.childNodes;
const list = node.childNodes;

// Using for..of
for (var value of list.values()) {
// 使用 for...of
for (const value of list.values()) {
console.log(value);
}
```

The result is:
结果为:

```
```plain
<p>
#text "hey"
<span>
```

## Browser compatibility
## 浏览器兼容性

{{Compat}}

## See also
## 参见

- [`core-js` 中 `NodeList.prototype.values` 的 polyfill](https://github.com/zloirock/core-js#iterable-dom-collections)
- {{domxref("Node")}}
- {{domxref("NodeList")}}