jQuery :input Selector

Beginner
7 min read
Updated: Oct 2026
5 examples
Live preview

What Is :input?

: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").

Remember
$(":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
NeedUse
All form controls$("form :input")
Only <input> tags$("input")
Native-friendly$("form *").filter(":input")
Text fields only$("input:text")
Buttons only$(":button")

How to Use :input

Scope to a form, then count, disable, serialize, or style every control.

  1. Prefer $("form :input") over bare $(":input") on large pages.
  2. Remember it includes textarea, select, and button — not just input.
  3. For speed: $("#form *").filter(":input") (official tip).
  4. Use type-specific selectors (:text, :checkbox, …) when you need one kind only.
  5. Compare with $("form > *") when labels/fieldsets sit as direct children.
PieceRequired?Role
Selector stringYes:input filter (best scoped to a form)
Form / contextRecommendedAvoids controls in unrelated widgets
.filter(":input")OptionalOfficial pattern after a pure CSS query
Return value—jQuery collection of form controls (may be empty)

Pseudocode

Pseudocode
matches = []
for each element in search context:
    if element.tag is input
       or element.tag is textarea
       or element.tag is select
       or element.tag is button:
        matches.add(element)

return matches

// Faster pattern:
candidates = querySelectorAll("form *")
return filter candidates with :input rules

Cheat Sheet

Keep these facts handy while selecting form controls.

TopicDetail
Syntax$(":input") / $("form :input")
SincejQuery 1.0 · jQuery extension
Matchesinput, textarea, select, button
vs $("input")Tag only — misses textarea/select/button
vs type filters:text, :checkbox, … are narrower
Speed tip$("form *").filter(":input")
Official demoCompare :input count vs form > *
Native CSSNo — use CSS + .filter()

Live Preview

Run different selectors against a small sample form and see how many controls match.

Sample markup mirrors the official jQuery form demo (label+text, textarea, select, checkbox, button).

Result
$(":input")
matched: 5

/* input + textarea + select + checkbox + button */

jQuery Examples

Short, copy-ready snippets. Open DevTools Console with jQuery loaded, or use Try It Yourself for a live editor.

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.
  4. Report. The demo prints both lengths in one sentence.

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.
  4. Sum. Tag counts add up to the :input total.

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.
  4. Habit. Always scope on multi-form pages.

Example 4 — Official Speed Tip: .filter(":input")

Select with pure CSS first, then filter — official performance advice.

jQuery
var $controls = $("#survey *").filter(":input");

$("#out").text("Filtered controls: " + $controls.length);

// Same idea with a form context:
// $("form").find("*").filter(":input")
Try It Yourself

How It Works

  1. CSS first. #survey * can use native querySelectorAll.
  2. Filter. .filter(":input") keeps only form controls.
  3. Result. Same matches as $("#survey :input"), often cheaper.
  4. When. Prefer this pattern on large DOMs or hot update paths.

Example 5 — Disable Every Form Control

One selector turns off all inputs, textareas, selects, and buttons in a form.

jQuery
$("#checkout :input").prop("disabled", true);

$("#out").text(
  "Disabled " + $("#checkout :input:disabled").length + " control(s)"
);
Try It Yourself

How It Works

  1. Select. #checkout :input targets every control in that form.
  2. Disable. .prop("disabled", true) locks each control.
  3. Verify. :disabled counts how many are now inactive.
  4. Use case. Handy while a submit request is in flight.

Edge Cases & Pitfalls

Check these before relying on :input in real forms.

slow

Bare $(":input") scans the whole page

Scope with $("form :input") or use $("form *").filter(":input").

confuse

:input ≠ $("input")

The tag selector misses textarea, select, and button.

non-std

Not valid in querySelectorAll

:input is a jQuery extension. Use CSS + .filter(":input") for native speed.

narrow

Too broad for one field type

Need only text or checkboxes? Use :text or :checkbox instead.

Browser Support

The :input pseudo-class is a jQuery extension and has worked since jQuery 1.0. There is no native CSS equivalent; combine a pure CSS query with .filter(":input") for best performance.

✓ jQuery 1.0+ · extension

jQuery :input Selector

Supported across jQuery 1.x, 2.x, and 3.x wherever your jQuery build runs. Prefer form :input; use .filter(":input") after a CSS query for speed.

100% jQuery extension
Google Chrome All versions · Desktop & Mobile
Full support
Mozilla Firefox All versions · Desktop & Mobile
Full support
Apple Safari All versions · macOS & iOS
Full support
Microsoft Edge All versions · Chromium & Legacy
Full support
Internet Explorer IE 6+ · Legacy environments
Full support
Opera All modern versions
Full support
:input Universal

Bottom line: Safe everywhere jQuery runs. Scope to a form; prefer $("form *").filter(":input") when performance matters.

Performance Notes

ApproachCostBest for
$("form *").filter(":input")FastestLarge forms / hot paths (official tip)
$("form :input")CheapTypical tutorials and small pages
$("#id :input")CheaperMulti-form pages
$(":input")SlowerAvoid — whole-document scan

Official jQuery docs note that because :input is not CSS, it cannot use the querySelectorAll boost. Select with a pure CSS selector first, then .filter(":input").

Key Takeaways

  • Role: select every form control — input, textarea, select, button.
  • Broader than tags: $(":input") ≠ $("input").
  • Scope: prefer $("form :input") on multi-form pages.
  • Speed: $("form *").filter(":input") — official performance tip.

One line: $("form :input") gathers every form control — broader than $("input") — and .filter(":input") after a CSS query is faster.

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

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

:text tutorial →

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