jQuery .prop() Method

Beginner
8 min read
Updated: Oct 2026
5 examples
Live preview

What Is .prop()?

.prop() (since 1.6) gets or sets live DOM properties on matched elements — runtime state like checked, disabled, and selectedIndex.

Remember
// Get (first element only)
var on = $("input").prop("checked");

// Set boolean state
$("input").prop("checked", true);
$("input").prop("disabled", false);

// Prefer .val() for typed text
$("input").val("someValue");
NeedUse
Live property (checked, disabled).prop()
HTML attribute (markup).attr()
Input / select text value.val()
Reset boolean property.prop(name, false) — not .removeProp()
Custom data.data()

How to Use .prop()

Same overload shapes as .attr(), but for properties.

  1. Select the element(s).
  2. Get: .prop("checked") — first match only.
  3. Set one: .prop("disabled", true) — every match.
  4. Set many: pass a plain object of property/value pairs.
  5. Compute: .prop("checked", function (i, val) { return !val; }).
SignatureSinceRole
.prop(name)1.6Get property on first element
.prop(name, value)1.6Set property on every match
.prop({ … })1.6Set several properties at once
.prop(name, fn)1.6Set from function(index, oldValue)

Pseudocode

Pseudocode
if called as .prop(name):
    return property name on first matched element
    // undefined if unset or empty selection

if called as .prop(name, value):
    for each matched element:
        set property name = value

if called as .prop(object):
    for each key in object:
        set that property on every matched element

if called as .prop(name, fn):
    for each matched element with index i:
        next = fn(i, currentProperty)
        if next is not undefined: set property to next

Cheat Sheet

Keep these facts handy for form and boolean state.

TopicDetail
SincejQuery 1.6
Getter scopeFirst element only
Return typeAnything (often boolean for form flags)
Property-onlyselectedIndex, tagName, nodeType, defaultChecked, …
Check if checked.prop("checked") or .is(":checked")
Input textPrefer .val(), not .prop("value")
Callback skipReturn undefined → leave value unchanged
Native cleanupSet false — never .removeProp() on natives

Live Preview

Toggle the sample checkbox with .prop(), or compare against .attr() and :checked.

Sample: the checkbox below. You can also click it, then Run → read.

Result
Ready — pick an action and click Run.

jQuery Examples

Short, copy-ready snippets. Prefer .val() for typed field text.

Example 1 — Official attr vs prop

Compare attribute, property, and :checked as the checkbox changes.

jQuery
$("input").on("change", function () {
  var $input = $(this);
  $("#out").text(
    "attr: " + $input.attr("checked") +
    " | prop: " + $input.prop("checked") +
    " | :checked: " + $input.is(":checked")
  );
}).trigger("change");
Try It Yourself

How It Works

  1. Listen. Update the readout on every change.
  2. attr. Initial markup attribute — does not track clicks.
  3. prop. Live boolean state of the checkbox.
  4. :checked. Selector form of the same live test.

Example 2 — Set checked

Turn a checkbox on with a boolean property setter.

jQuery
$("#agree").prop("checked", true);
$("#out").text("checked → " + $("#agree").prop("checked"));
Try It Yourself

How It Works

  1. Select. Target the checkbox by id.
  2. Set. .prop("checked", true) updates live state.
  3. Boolean. Prefer true/false, not strings.
  4. Verify. Read the property back with the getter.

Example 3 — Disable via Object

Official pattern: disable every checkbox with a properties object.

jQuery
$("input[type='checkbox']").prop({
  disabled: true
});

$("#out").text(
  "disabled count → " +
  $("input[type='checkbox']:disabled").length
);
Try It Yourself

How It Works

  1. Select. Match all checkbox inputs.
  2. Object. { disabled: true } sets the property on each.
  3. Effect. Controls become non-interactive.
  4. Count. Confirm with the :disabled filter.

Example 4 — Callback Toggle

Flip each checkbox based on its current property value.

jQuery
$("input[type='checkbox']").prop("checked", function (i, val) {
  return !val;
});

$("#out").text(
  $("input[type='checkbox']").map(function () {
    return $(this).prop("checked");
  }).get().join(", ")
);
Try It Yourself

How It Works

  1. Per element. The function runs once for each match.
  2. Args. i is the index; val is the old property.
  3. Flip. !val inverts the boolean.
  4. Skip. Returning undefined leaves that element unchanged.

Example 5 — selectedIndex

Property-only APIs like selectedIndex belong on .prop(), not .attr().

jQuery
$("#city").prop("selectedIndex", 2);
$("#out").text(
  "selectedIndex → " + $("#city").prop("selectedIndex") +
  " | value → " + $("#city").val()
);
Try It Yourself

How It Works

  1. Property-only. selectedIndex has no HTML attribute twin.
  2. Set. .prop("selectedIndex", 2) picks the third option.
  3. Read. Confirm with the getter.
  4. Value. Use .val() when you care about the option value string.

Edge Cases & Pitfalls

These trips up beginners most often.

boolean

Attribute ≠ live checked state

Use .prop("checked") or .is(":checked"). The attribute stays at the initial default.

remove

Never .removeProp() natives

Reset with .prop(name, false). .removeProp() is only for custom properties you added.

value

Prefer .val() for typed text

.prop("value") can work, but .val() is the dedicated, consistent API for form values.

property-only

Some names are properties only

selectedIndex, tagName, nodeType, and similar must use .prop() — not .attr().

Browser Support

.prop() was added in jQuery 1.6 to separate properties from attributes. Works wherever your loaded jQuery 1.6+ build runs.

✓ Stable · jQuery 1.6+

jQuery .prop()

Universal across browsers that run your jQuery version. Prefer current jQuery 3.x+ for consistent property handling.

100% jQuery core
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
.prop() Universal

Bottom line: Safe for everyday apps. Use .prop() for live form and DOM state; keep .attr() for markup attributes.

Performance Notes

ApproachCostBest for
One .prop() get/setCheapTypical form wiring
Object / callback on a setCheapBatch updates without re-querying
Huge loops with fresh selectorsCostlyCache the selection once

Property access is inexpensive. Prefer one selection plus a callback or object setter over repeated queries in tight loops.

Key Takeaways

  • Role: get/set live DOM properties since jQuery 1.6.
  • vs attr: properties are runtime state; attributes are markup.
  • Forms: name/value, object, or callback — getters are first-only.
  • Reset: .prop(name, false) — never .removeProp() on natives.

One line: .prop() talks to live DOM state — use it for checked, disabled, and property-only names.

Frequently Asked Questions

.prop() gets or sets DOM properties on matched elements. As a getter it returns the property value (any type, or undefined) for the first element only. As a setter it updates every matched element by name/value, plain object, or callback. Available since jQuery 1.6.
.prop() reads and writes live DOM properties (booleans like checked and disabled that change at runtime). .attr() reads and writes HTML attributes (initial markup, usually strings). For form state, use .prop() or .is(":checked").
Prefer .val() for input, textarea, and select values. Use .prop() for boolean and structural properties like checked, disabled, and selectedIndex.
No. .prop(name) returns the first element's property only. Loop with .each() or .map() to read each one. Setters apply to every matched element.
No. Do not call .removeProp() on native properties — it causes unexpected behavior. Reset with .prop("checked", false) or .prop("disabled", false). .removeProp() is for custom properties you added.
The checked attribute maps to the initial default (defaultChecked) and does not update on click. The checked property is a live boolean. Use .prop("checked") or .is(":checked") to test current state.

Next: .val() Method

Learn the dedicated API for reading and writing form field values.

.val() 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.

16 people found this page helpful