You are here: Reference > JavaScript > client-side > xml handling > properties > currentNode (TreeWalker)
currentNode property (TreeWalker)
9 | ||||
Sets or retrieves a reference to the node where the pointer of the TreeWalker is currently positioned.
Note: The TreeWalker object and its currentNode property are supported in Internet Explorer from version 9.
With the currentNode property you can set the current position of TreeWalker to a particular node.Syntax:
You can find the related objects in the Supported by objects section below.
This property is read/write.
Possible values:
Reference to the node where the TreeWalker is positioned.
Default: this property has no default value.
Example HTML code 1:
This example illustrates the use of the currentNode property:
|
||||
<head> <script type="text/javascript"> function ElementChecker (node) { if (node.tagName.toLowerCase () == 'button') { return NodeFilter.FILTER_ACCEPT; } return NodeFilter.FILTER_SKIP; } function FindFirstButton () { if (document.createTreeWalker) { walker = document.createTreeWalker (document.body, NodeFilter.SHOW_ELEMENT, ElementChecker, false); // get the first matching node var button = walker.firstChild (); alert ("The label of the first button element:\n" + button.textContent); // repeat the searching walker.currentNode = document.body; button = walker.firstChild (); alert ("The label of the first button element:\n" + button.textContent); } else { alert ("Your browser does not support the createTreeWalker method!"); } } </script> </head> <body> <button onclick="FindFirstButton ()">Find the first button tag with the TreeWalker object</button> </body> |
||||
|
||||
Did you find this example helpful?
|
Supported by objects:
Related pages:
External links:
User Contributed Comments