This page is Ready to Use

Notice: The WebPlatform project, supported by various stewards between 2012 and 2015, has been discontinued. This site is now available on github.

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