← Back to Index

.prop()

Get the value of a property for the first element or set one or more properties for every matched element.

Examples

1. Get Property

// <input type="checkbox" checked>
const isChecked = $('input').prop('checked');

Result

true

2. Set Property

$('input').prop('disabled', true);

Result

<input disabled>

3. Set with Function

$('input').prop('checked', (index, oldVal) => !oldVal);

Result

// Checkbox state is inverted

Parameters

Parameter Type Description
name string | object The name of the property (e.g., 'checked', 'disabled', 'selectedIndex'), or an object of property-value pairs.
value any | function The value to set. If a function, it is called for each element with (index, currentValue).

Returns: The property value for getter, or the original SR object for setter.