Posted By

dougunderscorenelson on 06/09/09


Tagged

javascript index jquery


Versions (?)

Who likes this?

3 people have marked this snippet as a favorite

sheedy
alejandrosuch
Meander365


Get index of the current element.


 / Published in: jQuery
 

Quickly get the index of the current element. I find myself re-using this several times in a document, so I made a lil' function for it.

  1. $.fn.getIndex = function(){
  2. var $p=$(this).parent().children();
  3. return $p.index(this);
  4. }

Report this snippet  

You need to login to post a comment.