jQuery :input Selector

Beginner
⏱️ 9 min read
📚 Updated: Jul 2026
🎯 5 Examples
🚀 5 Try-it labs
jQuery extension · jQuery 1.0+

What You’ll Learn

The :input selector matches every form control — input, textarea, select, and button elements — in one expression. jQuery extension since 1.0; official demo counts controls versus form children.

01

Syntax

:input

02

Controls

4 tag types

03

Official

Count demo

04

.filter()

Performance

05

vs input

Tag only

06

Scope

form :input

Introduction

Forms mix many control types — text fields, checkboxes, dropdowns, textareas, and buttons. When you need to style every control, disable a whole form, or count editable fields, listing each type separately is tedious. jQuery’s :input pseudo-class selects all form controls at once.

jQuery has supported :input since version 1.0. Official documentation states it selects all input, textarea, select, and button elements — basically every form control. Because it is a jQuery extension, prefer $("#form :input") or $("form *").filter(":input") over scanning the entire document with bare $(":input").

Understanding the :input Selector

:input matches these element types:

  • <input> (text, checkbox, radio, file, button, hidden, etc.) → matches.
  • <textarea> → matches.
  • <select> → matches.
  • <button> → matches.
  • <label>, <fieldset>, <option> alone → no match.
💡
Beginner Tip

$("input") selects only input tags. $(":input") is wider — it includes textarea, select, and button too. Pick the narrowest selector that fits your task.

📝 Syntax

Official jQuery API form (since 1.0):

jQuery
jQuery( ":input" )

// typical usage:
$( ":input" )
$( "form :input" )
$( "#signupForm :input" )

// performance pattern — CSS scope, then filter:
$( "form *" ).filter( ":input" )

// NOT the same as input tag selector:
$( "input" )   // input tags only

Parameters

  • None:input takes no arguments. It always means form controls (input, textarea, select, button).

Return value

  • A jQuery object containing every matched form control in document order within the search scope.
  • Empty collection when no controls exist in scope.

Official jQuery API example

jQuery
var allInputs = $( ":input" );
var formChildren = $( "form > *" );
$( "#messages" ).text(
  "Found " + allInputs.length + " inputs and the form has " +
  formChildren.length + " children."
);

⚡ Quick Reference

SelectorMatchesNotes
$(":input")input, textarea, select, buttonAll controls
$("input")input tags onlyNarrower
$("form :input")Controls in formScoped
$("form *").filter(":input")Same controlsPerformance
input:checkboxOne typeNot :input

📋 :input vs input tag, :text, and :button

Broad form controls vs tag selector vs type-specific pseudo-classes.

:input
form :input

All controls

input
form input

Input tags

:text
input:text

Text fields

:button
:button

Buttons only

Examples Gallery

Example 1 follows the official jQuery :input count demo. Examples 2–5 cover scoped .filter(":input"), comparison with the input tag, disabling all controls, and uniform styling.

📚 Official jQuery Demo

Count all form controls and compare to direct form children.

Example 1 — Official Demo: count :input

Official jQuery demo — report how many :input controls exist versus direct children of the form.

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

form > * includes labels and fieldsets; :input counts only interactive controls — the numbers differ by design in the official demo.

Example 2 — Performance: .filter(":input")

Official performance guidance — scope to a form with CSS, then filter to controls.

jQuery
var count = $( "#signupForm *" ).filter( ":input" ).length;
$( "#report" ).text( "Controls in #signupForm: " + count );
Try It Yourself

How It Works

Limit candidates before running the jQuery extension filter — faster than bare $(":input") on large pages.

📈 Practical Patterns

Tag comparison, disable form, uniform styling.

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

The input tag selector misses textarea, select, and button elements.

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

How It Works

When a form has a textarea or select, :input count is higher than $("input") count.

Example 4 — Disable Form: form :input

Disable every control in a form while leaving labels clickable for accessibility.

jQuery
$( "#lockedForm :input" ).prop( "disabled", true );
Try It Yourself

How It Works

One selector disables inputs, textareas, selects, and buttons together — common for read-only or loading states.

Example 5 — Uniform Width: style all :input

Apply consistent box sizing to every control in a fieldset.

jQuery
$( "fieldset :input" ).css({
  width: "100%",
  boxSizing: "border-box",
  marginBottom: "8px"
});
Try It Yourself

How It Works

Scoped fieldset :input styles every control type without targeting labels or legends.

🚀 Common Use Cases

  • Form audit — count controls with $("form :input").length as in the official demo.
  • Read-only mode.prop("disabled", true) on all :input in a form.
  • Uniform styling — one CSS pass for inputs, textareas, selects, and buttons.
  • Validation setup — attach handlers to every control in a wizard step.
  • Reset helpers — iterate form :input to clear values (with type checks).
  • Performance$("#form *").filter(":input") instead of document-wide scans.

🧠 How jQuery Evaluates :input

1

Build candidate set

Evaluate prefix — bare :input, form :input, or filtered descendants.

Query
2

Test tag name

Keep elements whose node name is input, textarea, select, or button.

Filter
3

Include all types

Every input type counts — text, hidden, checkbox, file, button, etc.

Union
4

Return collection

Chain .prop(), .css(), .on(), or read .length.

📝 Notes

  • Available since jQuery 1.0 — jQuery extension, not native CSS.
  • Matches input, textarea, select, and button — all form controls.
  • Not the same as $("input") — tag selector is narrower.
  • Prefer scoped queries — form :input or .filter(":input").
  • Does not match option elements unless they are also inputs (they are not).
  • Pair with :enabled, :disabled, or :checked for state filters.

Browser Support

The :input pseudo-class is a jQuery extension and works in jQuery 1.0+. Form controls themselves are universal in modern browsers. Scope with CSS first, then .filter(":input") when performance matters.

jQuery 1.0+ · extension

jQuery :input Selector

All form controls — input, textarea, select, and button.

100% jQuery + HTML
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: Scope to your form — avoid bare $(':input') on huge documents.

Conclusion

The :input selector matches every form control — input, textarea, select, and button. The official demo counts :input elements and compares that total to direct form children.

Use it for broad form operations, distinguish it from the input tag selector, and prefer scoped .filter(":input") on large pages.

💡 Best Practices

✅ Do

  • Use $("#form :input") for scoped queries
  • Use .filter(":input") after a CSS region selector
  • Pick input:checkbox when you only need one type
  • Combine with :enabled or :disabled
  • Count controls before wiring validation plugins

❌ Don’t

  • Confuse :input with $("input")
  • Run bare $(":input") on huge DOM trees
  • Expect :input to match labels or fieldsets
  • Use :input in native CSS stylesheets — jQuery-only
  • Disable labels when disabling :input — labels stay active

Key Takeaways

Knowledge Unlocked

Five things to remember about :input

Every form control in one selector.

5
Core concepts
4 02

Tags

in+ta+sel+btn

Rule
.filter 03

Scope

Performance

Tip
demo 04

Official

Count

Demo
05

input tag

Narrower

Compare

❓ 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 elements. Official docs describe :input as selecting all form controls.
No. It is a jQuery extension since version 1.0. Native querySelectorAll cannot run :input directly. Scope with a form selector, then use .filter(":input") as official docs recommend for performance.
: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.
Did you know?

jQuery provides many narrower form pseudo-classes — :text, :password, :radio, :checkbox, :submit, and more. Use :input when you need every control at once; use type-specific selectors when you only care about one kind.

Continue to :text Selector

Learn how to select single-line text input fields with the :text pseudo-class.

:text selector 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.

6 people found this page helpful