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
Fundamentals
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']").
Concept
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'].
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
Cheat Sheet
⚡ 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
Compare
📋 :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
Hands-On
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.
Buttons in #toolbar → class "toolbar-btn"
Same controls outside #toolbar → unchanged
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" );
button + input[type=button] → light blue background
Same elements as :button
How It Works
Because :button is a jQuery extension, splitting into standard CSS selectors lets jQuery delegate the first pass to the browser engine.
Applications
🚀 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
btn
Return collection
Matching controls become a jQuery object for chaining.
Important
📝 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").
Compatibility
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 ChromeAll versions · Desktop & Mobile
Full support
Mozilla FirefoxAll versions · Desktop & Mobile
Full support
Apple SafariAll versions · macOS & iOS
Full support
Microsoft EdgeAll versions · Chromium & Legacy
Full support
Internet ExplorerIE 6+ · Legacy environments
Full support
OperaAll modern versions
Full support
:buttonUniversal
Bottom line: Prefer $("button, input[type='button']") for native speed. Scope broad queries to a form or toolbar container.
Wrap Up
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.
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
Summary
Key Takeaways
Knowledge Unlocked
Five things to remember about :button
Button tag plus input type=button.
5
Core concepts
:btn01
:button
Two kinds
API
<btn>02
Tag
button element
Match
input03
type
= button
Match
≠04
Not submit
input submit
Compare
205
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.