Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jquery selector result is prevObject: e.fn.e.init[3] how do I get an element from that

Tags:

jquery

I have a selector $('.element') is returning prevObject: e.fn.e.init[3]. I looked into the results and the first object there is what I need. 2 questions here. What is prevObject? Also how can I select from the result the first object. Thanks for any help.

like image 795
user516883 Avatar asked Jul 08 '12 20:07

user516883


1 Answers

To access the first element, simply use [0] or .get(0)

prevObject is the result of the previous jQuery function call if the calls were chained together. It's what allows the .end() call to pop the jQuery chain back to a prior state.

like image 56
Alnitak Avatar answered Sep 28 '22 09:09

Alnitak