How to get the first child node of a specific HTML element in JavaScript

1 Answer

0 votes
<!DOCTYPE html> 
<html>
    <body>
        <ul id="ul_id"><li>JavaScript</li>
                       <li>PHP</li>
                       <li>SQL</li></ul>
        <script>
            var fc = document.getElementById("ul_id").firstChild.innerHTML;
            document.write(fc);
             
            /*
             run:
               
             JavaScript 
     
            */
        </script>
    </body>
</html>

 



answered Oct 25, 2019 by avibootz
edited Oct 25, 2019 by avibootz

Related questions

1 answer 164 views
1 answer 134 views
2 answers 409 views
...