Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

first child element javascript

Both these will give you the first child node:

console.log(parentElement.firstChild); // or
console.log(parentElement.childNodes[0]);

If you need the first child that is an element node then use:

console.log(parentElement.children[0]);
 
PREVIOUS NEXT
Tagged: #child #element #javascript
ADD COMMENT
Topic
Name
1+3 =