Problem with jQuery selector "+"

Today I found a weird jquery selector in the following code:

$(this).find("+div.parent").hide();

I searched for this in the jQuery API and found just what it means pre_element+next_element. What does +code do?

Thank.

+5
source share
4 answers

selector + corresponds to the element that follows the previous one

for example, if you want to combine everything divthat is in bold, you can use this selector:

$("b+div")

therefore, if $(this)referenced by <b>:

$(this).find('+div.parent')

will fit all divwith the class parentthat immediately after<b>

+6
source

+- Adjacent sibling selector

this, next()

$(this).find("+div.parent").hide();

$(this).next("div.parent").hide();
+4

He will find divwith the class parentnext to anyone $(this).

Spell here: http://jsfiddle.net/prbRA/1/

+2
source

Find all divs with the class parent immediately after the selected element $ (this)

+1
source

All Articles