-
Notifications
You must be signed in to change notification settings - Fork 22.4k
/
index.md
55 lines (39 loc) · 1023 Bytes
/
index.md
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
---
title: "TreeWalker: nextNode() method"
short-title: nextNode()
slug: Web/API/TreeWalker/nextNode
page-type: web-api-instance-method
browser-compat: api.TreeWalker.nextNode
---
{{ APIRef("DOM") }}
The **`TreeWalker.nextNode()`** method moves the current
{{domxref("Node")}} to the next _visible_ node in the document order, and returns
the found node. If no such node exists, it returns `null` and the current node is not changed.
## Syntax
```js-nolint
nextNode()
```
### Parameters
None.
### Return value
A {{domxref("Node")}} object or `null`.
## Examples
```js
const treeWalker = document.createTreeWalker(
document.body,
NodeFilter.SHOW_ELEMENT,
{
acceptNode(node) {
return NodeFilter.FILTER_ACCEPT;
},
},
false,
);
const node = treeWalker.nextNode(); // returns the first child of root, as it is the next node in document order
```
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
## See also
- The {{domxref("TreeWalker")}} interface it belongs to.