Published
- 1 min read
js find node number in div
The solution for this is noted below
js find node number in div
Solution
const child = document.getElementById('my_element')
const parent = child.parentNode
// The equivalent of parent.children.indexOf(child)
const index = Array.prototype.indexOf.call(parent.children, child)
Try other methods by searching on the site. That is if this doesn’t work