:button (since jQuery 1.0) selects every <button> element and every <input type="button">. It does not match submit or reset inputs. Official CSS equivalent: $("button, input[type='button']").
Syntax
Start with these common calls. Keep them short and readable.
jQuery collection of button controls (may be empty)
Load jQuery before your script (CDN or local file), then wrap DOM work in $(function () { ... }) when needed.
Parameters
Parameter
Description
":button"
Used in .filter(":button"). Official pattern after a pure CSS query
Return Value
Return Value
Description
See examples
Check the examples below for what this API returns in common cases.
jQuery Examples
Example 1 — Official Demo: Count :button
Mark all button controls and report how many matched (jQuery API example).
jQuery
var input = $(":button").addClass("marked");
$("div").text("For this type jQuery found " + input.length + ".");
// Prevent the form from submitting
$("form").on("submit", function (event) {
event.preventDefault();
});
true
Same result set; CSS form uses querySelectorAll
How It Works
Same intent. Both selectors target the same two element kinds.
Native path. The CSS string can use querySelectorAll.
Extension cost. Bare :button cannot use that boost.
Frequently Asked Questions
:button selects every button element and every input whose type is exactly button. It does not select input type submit, reset, checkbox, or other control types.
$("button") matches only <button> tags. $(":button") also includes input[type="button"]. If your form uses both, :button 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 :submit, not :button. A <button> element still matches :button even when type="submit", because it is a button tag.
Use $("button, input[type='button']") for native querySelectorAll speed, or select with a pure CSS selector then .filter(":button") as the official 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.