Skip to content
Advertisement

Finding child node’s index

I have a parent div with some nested elements in it. They have the same class name without an id.
How can I get the value of a specific child node?

Advertisement

Answer

add id to your parent element, then

let parent = document.getElementById('parentid');
let chil = parent.children;
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement