YouTip LogoYouTip

Sel Previous Next

body { font-family: Arial, sans-serif; line-height: 1.6; margin: 20px; } h1, h2, h3 { color: #333; } .example { background-color: #f4f4f4; padding: 15px; border-left: 5px solid #007bff; margin: 20px 0; } .note { background-color: #fff3cd; padding: 15px; border-left: 5px solid #ffc107; margin: 20px 0; } code { background-color: #f8f9fa; padding: 2px 6px; border-radius: 4px; font-family: monospace; } pre { background-color: #f8f9fa; padding: 15px; border-radius: 4px; overflow-x: auto; } .try-it { display: inline-block; background-color: #007bff; color: white; padding: 8px 16px; text-decoration: none; border-radius: 4px; margin-top: 10px; } .try-it:hover { background-color: #0056b3; } table { border-collapse: collapse; width: 100%; margin: 20px 0; } th, td { border: 1px solid #ddd; padding: 8px; text-align: left; } th { background-color: #f2f2f2; } .nav-links { margin: 20px 0; } .nav-links a { margin-right: 15px; color: #007bff; text-decoration: none; } .nav-links a:hover { text-decoration: underline; }

jQuery element + next Selector

Example

Select the next <p> element that is adjacent to each <div> element:

$("div + p")
Try it Yourself Β»

Definition and Usage

The ("element + next") selector selects the "next" element that is placed immediately after the specified "element". The "next" element must be placed right after the specified "element".

Example: If there are two <p> elements to the right of a <div> element, the syntax would be:

  • $("div + p") - Selects only the first <p> element, because it is the next element to the <div> element (the other <p> element will be ignored).

Example: If there is an <h2> element to the right of both the <div> element and the <p> element, the syntax would be:

  • $("div + p") - Will not select the <p> element, because the next element to the <div> element is the <h2> element.
Note: The two specified elements must share the same parent element.

Syntax

$("_element_ + _next_")
Parameter Description
element Required. Any valid jQuery selector.
next Required. Specifies the element that must be the next element to the element parameter.

More Examples

Select the next <div> element that is adjacent to each <ul> element.

Try it Yourself Β»
← Sel Previous SiblingsSel Parent Descendant β†’