VOOZH about

URL: https://www.geeksforgeeks.org/html/html-dom-children-property/

⇱ HTML DOM children Property - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

HTML DOM children Property

Last Updated : 9 Jun, 2023

The DOM children property is used to return an HTML collection of all the child elements of the specified element. The elements in the collection can be accessed by index numbers. It differs from childNodes as childNodes contain all nodes (i.e. it includes text and comment nodes as well) but on the other hand, children contain only element nodes. This is a read-only property. 

Syntax:

element.children

Return Value: It returns a collection of element nodes that can be accessed by indexing. 

Example 1: This example returns the number of list items. 

Output: 

👁 Image
 

Example 2: In this example, we will use  DOM children property

Output: 

👁 Image
 

Supported Browsers: The browser supported by DOM children property is listed below:

  • Google Chrome 1.0 and above
  • Edge 12.0 and above
  • Internet Explorer 9.0 and above
  • Firefox 3.5 and above
  • Opera 10.0 and above
  • Apple Safari 4.0 and above
Comment