English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

jQuery + Adjacent Sibling Selector

jQuery Selectors

Adjacent sibling selector (+)Selects the element placed after the first specified element (not inside).

Sibling elements must have the same parent element, 'adjacent' means 'immediately following'.

Syntax:

$("prev + next")

Example

Select each <div> element next to the <p> element:

$(document).ready(function(){
  $("div + $("p").css("background", "mediumpurple");
});
Test and see‹/›

Parameter Value

ParameterDescription
prevAny valid selector
nextA selector that matches the element next to the first selector

jQuery Selectors