jQuery .prop() Method

Beginner
5 min read
Updated: Nov 2026
3 examples
Attributes

Definition

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

Syntax

Start with these common calls. Keep them short and readable.

jQuery
// 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");
CallWhat it does
.prop(name)Get property on first element
.prop(name, value)Set property on every match
.prop({ … })Set several properties at once
.prop(name, fn)Set from function(index, oldValue)

Load jQuery before your script (CDN or local file), then wrap DOM work in $(function () { ... }) when needed.

Parameters

ParameterDescription
nameUsed in .prop(name). Get property on first element
valueUsed in .prop(name, value). Set property on every match
objectUsed in .prop({ … }). Set several properties at once
fnUsed in .prop(name, fn). Set from function(index, oldValue)

Return Value

Return ValueDescription
BooleanOften true or false depending on the match or state.
jQuery objectMost setters and traversing helpers return the jQuery collection so you can chain more methods.
Value / undefinedGetters usually return a value from the first matched element, or undefined when nothing applies.

jQuery Examples

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.

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.

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.

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() Method tutorial →

CODETOFUN NEWS

Stay Ahead in Tech

Get the latest IT news, programming updates, and technology trends directly on your phone.

Your daily dose of tech, straight to your feed.

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