-1

I am using the following to get a list of DIVS;

var $items = $this.children("div.poster");

How can I get the element in position 4 from $items if it exists?

Miguel Moura
  • 36,732
  • 85
  • 259
  • 481

1 Answers1

1

Use the .eq() method:

var $item4 = $items.eq(3);

To get the position of an item, use .index()

var position = $item4.index($items);
Barmar
  • 741,623
  • 53
  • 500
  • 612