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/
Top comments (0)