What is the difference between firstChild and firstElementChild in Javascript?
Vijay SRJ
Posted on November 11, 2020
The difference between firstChild and firstElementChild can sometimes be confusing.
firstChild considers both text and comment between html tags as child whereas firstElementChild does not.
The text also includes empty space which can be missed out..
Here is an example demo:
https://fullstackdeveloper.guru/2020/11/11/what-is-the-difference-between-firstchild-and-firstchildelement-in-javascript/
💖 💪 🙅 🚩
Vijay SRJ
Posted on November 11, 2020
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.