jQuery:Selector prev + next

Overview

Matches all the next elements immediately after the prev element.

Parameter

prevSelectorV1.0

Any valid selector.

nextSelectorV1.0

A valid selector and immediately following the first selector.

Demo

 

Description:

Matches all input elements following label.

HTML code:
<form>
  <label>Name:</label>
  <input name="name" />
  <fieldset>
      <label>Newsletter:</label>
      <input name="newsletter" />
 </fieldset>
</form>
<input name="none" />
jQuery code:
$("label + input")
Result:
[ <input name="name" />, <input name="newsletter" /> ]

Leave a Reply

Your email address will not be published. Required fields are marked *