28-09-2011

jQuery Find index of element relative to parent

the following shows how you can quickly see what the index of an element is, using the prevAll() method

 
var index = $(this).prevAll().length;  
 

.prevAll() gets all preceding siblings of each element in the set of matched elements, optionally filtered by a selector.

Comments:

Your comment:

»

 

[x]