Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

jQuery element + next Selector

jQuery element + next Selector

jQuery selector jQuery selector

Example

Select the element adjacent to each

the one immediately after the ... element

element:

$("div + p")

Try it »


Definition and Usage

The ("element + next") selector selects the "next" element following the specified "element". The "next" element must be placed immediately to the right of the specified "element".

Example: if an

element has two

elements to its right, the syntax is as follows:

  • $("div + p") - Only the first

    element is selected, because it is

    the next element of the

    element (the other element is ignored)

Example: if an

element and

If there is one ... element to the right

elements to its right, the syntax is as follows:

  • $("div + p") - will not be selected

    the element, because

    the next element of the ... element is

    Element

**Note:** The two specified elements share the same parent element.


Syntax

("

element

next

")

Parameters Description
element Required. Any valid jQuery selector.
next Required. Specifies the element, which must be a element sibling of the next .

Try it - Example

Select every