Is there a general way to index in jQuery? I know there's .first() but how about .second() or .third() -
this question has answer here:
- get element index in jquery 5 answers
this seems pretty simple question couldn't find answer. have 3 forms on side open when button pressed , want autofocus cursor on whichever 1 of forms opens up. because forms identical, i'm having trouble referencing individual one, , it's on squarespace can't add id. grateful on this. thanks!
you use .eq()
method. supply index (they 0 based).
given jquery object represents set of dom elements,
.eq()
method constructs new jquery object 1 element within set. supplied index identifies position of element in set.