jQuery:Selector parent > child

Overview

Select all child elements under a given parent element.

Parameter

parentSelectorV1.0

Any valid selector.

childSelectorV1.0

A selector to match the element, and it is a child of the first selector.

Demo

Description:

Select all child input elements of 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="name" /> ]

Leave a Reply

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