Reputation: 51333
I have...
element = document.elementFromPoint(x, y)
then I want to do something like...
index = $(element).index()
The DOM element is a li
and I need its position in the list.
Thanks!
EDIT: If what i'm doing is correct then something here is wrong, Touch events over two dom elements?
Any help is much appreciated.
Upvotes: 1
Views: 1891
Reputation: 1585
$(element) will work, if you want to know its position you need to select it's preceding siblings.
jQuery than gives you the length property, wich works like on arrays.
$(element).prevAll().length;
Upvotes: 3
Reputation: 179046
What you want is $('li').index(element);
index()
docs allows you to pass a selector or DOM element as a parameter to work similarly to indexOf
.
Upvotes: 1