jQuery :button Selector

Beginner
⏱️ 8 min read
📚 Updated: Jul 2026
🎯 5 Examples
🚀 5 Try-it labs
Form controls

What You’ll Learn

The :button selector matches button elements and input elements with type="button". It is a jQuery extension (since 1.0) — useful when one form mixes both tag types and you want every plain button control in one query.

01

Syntax

:button

02

<button>

Tag matches

03

input

type=button

04

Official

.addClass

05

vs submit

Not :submit

06

CSS alt

button, input

Introduction

HTML forms offer two ways to create clickable buttons: the <button> element and <input type="button">. Styling or wiring click handlers for “all the plain buttons” means selecting both shapes — not submit buttons, not text fields.

jQuery’s :button pseudo-class gathers those controls in one expression. It has existed since jQuery 1.0. Official docs note it is not standard CSS; the equivalent valid selector is $("button, input[type='button']").

Understanding the :button Selector

Think of :button as a filter for “button-shaped” controls that are not submit, reset, or other specialized input types.

  • <button>Click</button> → matches (button tag).
  • <input type="button" value="Go"> → matches.
  • <input type="submit" value="Send"> → no match (use :submit).
  • <input type="text"> → no match.
💡
Beginner Tip

$("button") only selects <button> tags. If your page also uses <input type="button">, switch to :button or the CSS combo button, input[type='button'].

📝 Syntax

Official jQuery API form (since 1.0):

jQuery
jQuery( ":button" )
// shorthand:
$( ":button" )

// scoped:
$( "form :button" )
$( "#toolbar button, #toolbar input[type='button']" ) // CSS equivalent

Parameters

  • No arguments — the pseudo-class matches by element type and input type attribute.

Return value

  • A jQuery object containing every matching button control in the search context.
  • Empty collection when no button or input[type=button] elements exist.

Official jQuery API example

jQuery
var input = $( ":button" ).addClass( "marked" );
$( "div" ).text( "For this type jQuery found " + input.length + "." );

// Official demo matches 2: input[type="button"] + button element

⚡ Quick Reference

Element:button
<button>OK</button>Matches
<input type="button">Matches
<button type="submit">Matches (still a button tag)
<input type="submit">No match
<input type="reset">No match
<input type="text">No match

📋 :button vs button vs input[type='button']

Three ways to target buttons — jQuery pseudo, tag only, and attribute only.

:button
$(":button")

Tag + input type

Tag
$("button")

button elements only

Attr
input[type='button']

input controls only

CSS combo
button, input[type='button']

Native equivalent

Examples Gallery

Example 1 follows the official jQuery API demo. Examples 2–5 compare selectors, contrast with :submit, scope to a form, and use the CSS-equivalent pattern. Use the Try-it links to run each snippet.

📚 Official jQuery Demo

Mark every :button in a mixed form and report the count.

Example 1 — Official Demo: $(":button").addClass("marked")

Official jQuery demo — add class marked to all button controls and display how many matched.

jQuery
var input = $( ":button" ).addClass( "marked" );
$( "#count" ).text( "For this type jQuery found " + input.length + "." );

// Matches: input[type="button"] and <button>
// Skips: submit, reset, text, checkbox, etc.
Try It Yourself

How It Works

jQuery walks form controls and applies the :button filter. Submit and text inputs are ignored even though they live in the same form.

Example 2 — Compare :button, button, and input[type='button']

See how many elements each selector finds on the same markup.

jQuery
console.log( ":button →", $( ":button" ).length );
console.log( "button tag →", $( "button" ).length );
console.log( "input[type=button] →", $( "input[type='button']" ).length );

// Typical form: :button count = tag count + input type=button count
Try It Yourself

How It Works

When a form uses both <button> and <input type="button">, only :button (or the CSS combo) selects all plain button controls in one call.

📈 Practical Patterns

Submit contrast, scoped queries, and performance-friendly CSS.

Example 3 — :button vs :submit

Disable plain buttons while leaving submit controls enabled for form posting.

jQuery
$( ":button" ).prop( "disabled", true );
$( ":submit" ).prop( "disabled", false );

// :button → button tag + input[type=button]
// :submit → input[type=submit] + button[type=submit]
Try It Yourself

How It Works

jQuery provides separate form pseudo-classes for each input type. Mixing them lets you style or toggle groups without listing every selector manually.

Example 4 — Scoped Buttons $("#toolbar :button")

Target button controls inside one toolbar container only.

jQuery
$( "#toolbar :button" ).addClass( "toolbar-btn" );

// Matches buttons inside #toolbar
// Ignores buttons elsewhere on the page
Try It Yourself

How It Works

Prefix with an ID or class so :button does not scan the entire document — especially helpful on pages with many forms.

Example 5 — CSS Equivalent $("button, input[type='button']")

Official jQuery recommendation — same selection with native querySelectorAll support.

jQuery
// Same result as $(":button"), often faster:
$( "button, input[type='button']" ).css( "background-color", "#dbeafe" );

// Or narrow after a CSS scope:
$( "#form input" ).filter( ":button" );
Try It Yourself

How It Works

Because :button is a jQuery extension, splitting into standard CSS selectors lets jQuery delegate the first pass to the browser engine.

🚀 Common Use Cases

  • Form styling — highlight every plain button in a dialog.
  • Disable controls — lock UI buttons during AJAX without disabling submit.
  • Click wiring — attach handlers to all toolbar button controls at once.
  • Accessibility audit — count button-shaped controls in a form region.
  • Legacy markup — pages mixing <button> and <input type="button">.
  • Plugin init — pass form :button to a button-enhancement plugin.

🧠 How jQuery Evaluates :button

1

Collect candidates

Start from the search context — document, form, or scoped container.

Scope
2

Check tag or type

Match button elements or input with type="button".

Filter
3

Skip other types

Submit, reset, text, and checkbox inputs fail the :button test.

Exclude
4

Return collection

Matching controls become a jQuery object for chaining.

📝 Notes

  • Available since jQuery 1.0 — jQuery extension, not standard CSS.
  • CSS equivalent: $("button, input[type='button']") per official docs.
  • All <button> tags match, including type="submit" on the tag.
  • input[type="submit"] matches :submit, not :button.
  • For performance, prefer the CSS combo or .filter(":button") after scoping.
  • Pair with form context: $("#myForm :button").

Browser Support

The :button selector ships with jQuery 1.0+. Browser compatibility follows your jQuery version — the pseudo-class itself has no separate native CSS support because it is a jQuery invention.

jQuery 1.0+ · Extension

jQuery :button Selector

Works wherever full jQuery runs — all modern browsers and legacy IE with supported jQuery builds. Not available in querySelectorAll; use button, input[type='button'] instead.

100% With jQuery
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
:button Universal

Bottom line: Prefer $("button, input[type='button']") for native speed. Scope broad queries to a form or toolbar container.

Conclusion

The :button selector matches <button> elements and <input type="button"> controls in one jQuery query. The official demo, $(":button").addClass("marked"), marks both kinds in a mixed form and reports the match count.

Use it when forms mix tag types; prefer $("button, input[type='button']") when you need native selector performance. Scope to a form or toolbar to keep queries fast on large pages.

💡 Best Practices

✅ Do

  • Use button, input[type='button'] for native performance
  • Scope: $("#form :button") on large pages
  • Distinguish :button from :submit in forms
  • Count matches with .length like the official demo
  • Prefer <button type="button"> for non-submit actions

❌ Don’t

  • Assume $("button") selects input[type=button]
  • Use bare $(":button") on huge DOM trees without scoping
  • Expect :button in native querySelectorAll
  • Confuse input[type=submit] with :button
  • Disable all :button when you meant to keep submit enabled

Key Takeaways

Knowledge Unlocked

Five things to remember about :button

Button tag plus input type=button.

5
Core concepts
<btn> 02

Tag

button element

Match
input 03

type

= button

Match
04

Not submit

input submit

Compare
2 05

Official

Demo count

Demo

❓ Frequently Asked Questions

:button selects every button element in the DOM and every input element whose type attribute is exactly button. It does not select input type submit, reset, checkbox, or other control types.
$("button") matches only button elements. $(":button") also includes input[type="button"]. If your form uses both tags, :button is the one selector that gathers both kinds.
No. It is a jQuery extension since version 1.0. The CSS-equivalent selector is $("button, input[type='button']"). Native querySelectorAll cannot run :button directly.
No. input[type="submit"] is matched by the :submit pseudo-class, not :button. However, a button element with type="submit" still matches :button because it is a button tag.
Use $("button, input[type='button']") for native querySelectorAll speed, or select a container with a CSS selector then narrow with .filter(":button") as jQuery docs recommend.
In the official jQuery form demo, :button finds two elements — one input[type="button"] and one button element — while skipping submit, reset, text, and other controls.
Did you know?

jQuery ships a family of form pseudo-classes — :button, :submit, :reset, :checkbox, :radio, :text, and more. Each maps input types and button tags so you can target form controls without memorizing every type attribute value.

Continue to :checkbox Selector

After button controls, learn how to select every input[type=checkbox] with :checkbox.

:checkbox 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