Home > JQuery > jQuery – Get a childs relative position

jQuery – Get a childs relative position

January 13th, 2011 Leave a comment Go to comments

When processing sortables etc. Its handy to be able to get the index of individual items. Heres how you find the position of an li within a list:

var position = $item.parent().find('> li').index($item) + 1;
Categories: JQuery Tags:
  1. No comments yet.
  1. No trackbacks yet.