Latest web development tutorials

jQuery element + next selector

jQuery selector jQuery selector

Examples

Select each <div> element in the next adjacent <p> element:

$("div + p")

try it"

Definition and Usage

( "Element + next") picker to select the specified element "element" under the element "next". "Next" element must be placed in the specified element "element" of the right.

Example: If the right of the <div> element with two <p> element, the syntax is as follows:

  • $ ( "div + p") - Select only the first <p> element, because it is the next element <div> element (another <p> element will be ignored)

Example: If the <div> element on the right and <p> element has an <h2> element, the syntax is as follows:

  • $ ( "div + p") - will not pick <p> element, because the next element <div> element is <h2> element

Note: Two elements specified share the same parent element.


grammar

(" element + next ")

参数 描述
element 必需。任何有效的 jQuery 选择器。
next 必需。规定元素,必须是element参数的next元素。


Examples

Try - Example

Select each of the <ul> element next adjacent <div> element
How to select each of the <ul> element next adjacent <div> element.


jQuery selector jQuery selector