firstChild
Summary
Retrieves a reference to the first child of the current node of the filtered TreeWalker hierarchy and updates currentNode.
Method of dom/TreeWalkerdom/TreeWalker
Syntax
var node = treewalker.firstChild(/* see parameter list */);
Parameters
oNode
- Data-type
- any
Object that receives the first child node in the filtered TreeWalker hierarchy.
Return Value
Returns an object of type DOM NodeDOM Node
Object that receives the first child node in the filtered TreeWalker hierarchy.
Examples
var treewalker = document.createTreeWalker(
document.body,
NodeFilter.SHOW_ELEMENT,
{ acceptNode: function(node) { return NodeFilter.FILTER_ACCEPT; } },
false
);
var node = treewalker.firstChild(); // returns the first child of the root element, or null if none
Notes
Remarks
firstChild sets the currentNode to the returned node.
Syntax
Standards information
Related specifications
- DOM
- Living Standard
Attributions
Mozilla Developer Network : [TreeWalker.firstChild Article]
Microsoft Developer Network: [firstChild Method Article]