HTML | DOM firstElementChild Property
The HTML DOM firstElementChild Property will return the first child of any node PreRequist DOM (Document Object Model)
Parameters:
No parameters required.
Return value:
The values returned by firstElementChild property are following:
Syntax
node.firstElementChild()
Example:
<!DOCTYPE html> <html> <head> <head> HTML | DOM firstElementChild Property </head> <script> // JavaScript code to get the node whose // id is "Section" function example() { // x is used to store the element // whose id is "Sections". var x = document.getElementById("Sections" + ).firstElementChild.innerHTML; document.getElementById("GeeksForGeeks sections" + " first node").innerHTML = x; } </script> </head> <body> <p>GeeksForGeeksTopics</p> <ul id="Sections"> <li>Array</li> <li>LinkedList</li> <li>Stack</li> <li>Queue</li> <li>Tree</li> <li>Graph</li> </ul> <p> Click the button to get the first child of the node having id is "Sections". </p> <!--button is used to run example function--> <button onclick="example()">Click</button> <p id="GeeksForGeeks sections first node"></p> </body> </html> |
chevron_right
filter_none
Output

Supported Browsers: The browser supported by DOM firstElementChild are listed below:
- Google Chrome
- Internet Explorer
- Firefox
- Opera
- Safari
Recommended Posts:
- HTML | DOM li value Property
- HTML | DOM Map name Property
- HTML | DOM value Property
- HTML | DOM URL Property
- HTML | DOM name Property
- HTML | DOM specified Property
- HTML | DOM id Property
- HTML | DOM dir Property
- HTML | DOM Bdo dir Property
- HTML | DOM Button value Property
- HTML | DOM innerHTML Property
- HTML | DOM offsetLeft Property
- HTML | DOM accessKey Property
- HTML | DOM previousElementSibling Property
- HTML | DOM innerText Property
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



