Next Adjacent Selector (“prev + next”)

next adjacent selector

Description: Selects all next elements matching "next" that are immediately preceded by a sibling "prev".

  • version added: 1.0jQuery( "prev + next" )

    prev: Any valid selector.

    next: A selector to match the element that is next to the first selector.

One important point to consider with both the next adjacent sibling selector (prev + next) and the general sibling selector (prev ~ siblings) is that the elements on either side of the combinator must share the same parent.


Finds all inputs that are next to a label.

<!doctype html>
<html lang="en">
  <meta charset="utf-8">
  <title>next adjacent demo</title>
  <script src="https://code.jquery.com/jquery-3.5.0.js"></script>
  <label for="name">Name:</label>
  <input name="name" id="name">
    <label for="newsletter">Newsletter:</label>
    <input name="newsletter" id="newsletter">
<input name="none">
$( "label + input" ).css( "color", "blue" ).val( "Labeled!" );


© The jQuery Foundation and other contributors
Licensed under the MIT License.