Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Inverse of Next Siblings Selector

Tags:

jquery

sizzle

So I came across the Next Sibling Selector on the jQuery docs today:

$("label + input")

And was wondering - is there an inverse of this selector? i.e. select the Previous Sibling?

I could use:

$("label + input").prev()

For example in this fiddle, I get all labels in which a label is followed by an input, which is what I want, but is this the only way to do it?

like image 888
CodingIntrigue Avatar asked Dec 18 '25 21:12

CodingIntrigue


1 Answers

You can use array provided by sibling()

Check this out:

http://api.jquery.com/category/traversing/tree-traversal/

like image 145
Amin Avatar answered Dec 21 '25 12:12

Amin