You are here: Reference > JavaScript > client-side > xml handling > properties > root (NodeIterator, TreeWalker)
root property (NodeIterator, TreeWalker)
9 | ||||
Returns the root element that was used to create the NodeIterator or TreeWalker object.
Note: The TreeWalker and NodeIterator objects and their root properties are supported in Internet Explorer from version 9.
This property can be set by the first parameter of the createNodeIterator and createTreeWalker methods.Syntax:
You can find the related objects in the Supported by objects section below.
This property is read-only.
Possible values:
Reference to the root element.
Default: this property has no default value.
Example HTML code 1:
This example illustrates the use of the root property:
|
||||
<head> <script type="text/javascript"> function TestRoot () { if (document.createTreeWalker) { var walker = document.createTreeWalker (document.body, NodeFilter.SHOW_ALL, null, true); alert ("The tag name of the root element: " + walker.root.tagName); } else { alert ("Your browser does not support the createTreeWalker method!"); } } </script> </head> <body> <button onclick="TestRoot ()">Test root property</button> </body> |
||||
|
||||
Did you find this example helpful?
|
Supported by objects:
Related pages:
External links:
User Contributed Comments