Skip to content
Related Articles

Related Articles

HTML | DOM firstElementChild Property
  • Difficulty Level : Medium
  • Last Updated : 25 Jul, 2019

The HTML DOM firstElementChild Property will return the first child of any node PreRequist DOM (Document Object Model)

No parameters required.

Return value:
The values returned by firstElementChild property are following:

  • A Node object: Representing the first child element of an element.
  • Null: If there are no child elements.




    <!DOCTYPE html>
            HTML | DOM firstElementChild Property
            // 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;
        <ul id="Sections">
          Click the button to get the first child
          of the node having id is "Sections".
        <!--button is used to run example function-->
        <button onclick="example()">Click</button>
        <p id="GeeksForGeeks sections first node"></p>


    Supported Browsers: The browser supported by DOM firstElementChild are listed below:

    • Google Chrome
    • Internet Explorer
    • Firefox
    • Opera
    • Safari

    My Personal Notes arrow_drop_up
  • Recommended Articles
    Page :