jQuery :input Selector

Beginner
5 min read
Updated: Nov 2026
3 examples
Selectors

Definition

:input (since jQuery 1.0) selects every form control — input, textarea, select, and button. It is broader than $("input"), which matches only <input> tags. Scope to a form when you can; on large pages prefer $("form *").filter(":input").

Syntax

Start with these common calls. Keep them short and readable.

jQuery
$(":input")                     // all form controls
$("form :input")                // controls inside a form
$("form *").filter(":input")    // official performance pattern
$("input")                      // <input> tags only — narrower!

// Avoid on large pages:
$(":input")                     // whole-document scan
CallWhat it does
Selector string:input filter (best scoped to a form)
Form / contextAvoids controls in unrelated widgets
.filter(":input")Official pattern after a pure CSS query
Return valuejQuery collection of form controls (may be empty)

Load jQuery before your script (CDN or local file), then wrap DOM work in $(function () { ... }) when needed.

Parameters

ParameterDescription
":input"Used in .filter(":input"). Official pattern after a pure CSS query

Return Value

Return ValueDescription
See examplesCheck the examples below for what this API returns in common cases.

jQuery Examples

Example 1 — Official Demo: Count :input

Compare form-control count with direct form children (jQuery API example).

jQuery
var allInputs = $(":input");
var formChildren = $("form > *");

$("#messages").text(
  "Found " + allInputs.length + " inputs and the form has " +
  formChildren.length + " children."
);
Try It Yourself

How It Works

  1. Controls. $(":input") gathers every form control on the page.
  2. Children. $("form > *") counts only direct children of the form.
  3. Compare. Labels and fieldsets can make the two counts differ.

Example 2 — :input vs $("input")

The tag selector misses textarea, select, and button.

jQuery
console.log(":input →", $(":input").length);
console.log("input tag →", $("input").length);
console.log("textarea →", $("textarea").length);
console.log("select →", $("select").length);
console.log("button →", $("button").length);
Try It Yourself

How It Works

  1. Broad. :input includes all four control tags.
  2. Narrow. $("input") matches only <input> elements.
  3. Split. Textarea, select, and button are counted separately by tag.

Example 3 — Scope to One Form

Limit :input so other forms on the page are ignored.

jQuery
var $signup = $("#signup :input");
var $login = $("#login :input");

$("#out").text(
  "signup controls: " + $signup.length +
  " · login controls: " + $login.length
);
Try It Yourself

How It Works

  1. Context. #signup :input searches only inside that form.
  2. Isolation. Login controls never appear in the signup set.
  3. Count. Each form reports its own control total.

Frequently Asked Questions

:input selects every form control — input, textarea, select, and button elements. It is the broadest jQuery form pseudo-class for gathering editable and submittable controls. Available since jQuery 1.0.
No. $("input") matches only <input> tags. $(":input") also includes textarea, select, and button. Official docs describe :input as selecting all form controls.
No. It is a jQuery extension (not part of the CSS specification), so queries using :input cannot use the native querySelectorAll boost. Official tip: select with a pure CSS selector first, then .filter(":input").
:text, :checkbox, :file, and similar pseudo-classes match one input type. :input matches every form control type at once — inputs, textareas, selects, and buttons.
Official jQuery demo runs var allInputs = $(":input") and compares .length to $("form > *").length — showing how many form controls exist versus direct form children (which may include labels and fieldsets).
Prefer scoping — $("#myForm :input") or $("form *").filter(":input"). Bare $(":input") scans the entire document and is slower on large pages.

Next: :text Selector — Select Text Inputs

Learn how to select text input fields with the :text selector.

:text Selector — Select Text Inputs tutorial →

CODETOFUN NEWS

Stay Ahead in Tech

Get the latest IT news, programming updates, and technology trends directly on your phone.

Your daily dose of tech, straight to your feed.

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

9 people found this page helpful