Skip to content

Commit

Permalink
zh-cn: update the translation of NodeList.values() (#23299)
Browse files Browse the repository at this point in the history
  • Loading branch information
yin1999 authored Aug 30, 2024
1 parent aa9f5a1 commit 8ee5fbb
Showing 1 changed file with 22 additions and 19 deletions.
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")}}

0 comments on commit 8ee5fbb

Please sign in to comment.