jQuery:Selector prev ~ siblings

Overview

Matches all siblings elements after the prev element.

Parameter

prevSelectorV1.0

Any valid selector.

siblingsSelectorV1.0

A selector, and it acts as a sibling of the first selector.

Demo

Description:

Find all input elements that are peers to the form.

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

Leave a Reply

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