Search
 
SCRIPT & CODE EXAMPLE
 

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]);
Comment

PREVIOUS NEXT
Code Example
Javascript :: append before jquery 
Javascript :: fontawsome icon size react element 
Javascript :: Ignoring TypeScript Errors in next js 
Javascript :: eslint console log 
Javascript :: js get time in am 
Javascript :: slider is not a function jquery 
Javascript :: js get first object value 
Javascript :: generate random number javascript 
Javascript :: javascript distance between two points 
Javascript :: jquery if checkbox checked 
Javascript :: jquery scroll to bottom 
Javascript :: window viewport size javascript 
Javascript :: javascript anagram check 
Javascript :: generate jwt secret key 
Javascript :: node sleep 
Javascript :: creating new react app 
Javascript :: javascript keypress backspace not working 
Javascript :: lowercase or uppercase all strings in array javascript 
Javascript :: js startswith 
Javascript :: jest expect async function to throw error 
Javascript :: how to reset form after submit using jquery and ajax 
Javascript :: discord bot status javascript 
Javascript :: open new tab with javascript 
Javascript :: get params js 
Javascript :: change favicon with javascript 
Javascript :: js sleep sync 
Javascript :: keyboard arrow event handling javascript 
Javascript :: nginx rewrite proxy_pass 
Javascript :: js number to hex 
Javascript :: jquery reset select2 
ADD CONTENT
Topic
Content
Source link
Name
4+3 =