-
Notifications
You must be signed in to change notification settings - Fork 0
getIndex
Mike Byrne edited this page Jan 25, 2022
·
2 revisions
Returns the index of a node in a nodeList
- nothing
- node - required - what you want to find the index of
- nodeList - optional - what you want to find the index in, if none specified it looks at the node's parent
- index of node
var index = getIndex(el);
var links = document.querySelectorAll('a');
var clickedLink = event.target;
var index = getIndex(clickedLink, links);