:password selects every element of type password — usually <input type="password">. Official docs: equivalent to $("[type=password]"). Available since jQuery 1.0.
Syntax
Start with these common calls. Keep them short and readable.
jQuery
$("input:password") → recommended
$("[type=password]") → equivalent (official)
$("input[type='password']") → best for modern browsers
$(":password") → means *:password (avoid)
<input type="password"> → matches
<input type="text"> → no match
Call
What it does
input prefix
Avoids universal *:password scan
:password
Keeps type=password controls
Form context
Limits matches to one form
Load jQuery before your script (CDN or local file), then wrap DOM work in $(function () { ... }) when needed.
Parameters
Parameter
Description
Step 1
Write input:password (not bare :password).
Step 2
Scope to a form when the page has many fields: $("#login input:password").
Step 3
For speed in modern browsers, use input[type="password"].
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: input:password
Count password inputs in a mixed form (jQuery API example idea).
jQuery
var $input = $("input:password");
console.log("For this type jQuery found " + $input.length + ".");
console.log("names:", $input.map(function () {
return this.name || "(no name)";
}).get().join(", "));
Typed form. Official recommendation: precede with a tag.
Bare form. Means *:password — wider scan.
Same on tiny demos. Counts often match by coincidence.
Frequently Asked Questions
:password selects every element of type password — typically <input type="password">. $("input:password") finds all password fields in scope. Available since jQuery 1.0.
Yes. Official docs: $( ":password" ) is equivalent to $( "[type=password]" ). For native querySelectorAll speed, prefer input[type="password"].
Prefer $("input:password"). Bare $(':password') implies the universal selector ($('*:password')). Official docs recommend preceding it with a tag name.
No. It is a jQuery extension. Native querySelectorAll cannot run :password. Use input[type="password"] for standard CSS matching.
:password matches masked password inputs. :text matches plain text inputs. They never overlap.
It styles $("input:password") and reports how many were found in a sample form that also includes text, textarea, checkbox, radio, select, and button controls.