Back

.prop( name, [value] )

Get or set properties on the current set

If value is provided, this will set the property on each element and return the current set for chaining

If value is not passed, this will return the value of the property for the first element in the current set

There is a difference between attr vs prop

Params

name{String}The name of the property
value{Any} [optional]A value to be set. Most values will be converted to a String before setting. Functions will be evaluted with (previousValue, index) and the return value will be set.

Returns

Value or DollarJS (chainable)

Examples

$('input').prop('checked')
$('input').prop('checked', true)
$('input').prop('checked', function(previousValue, index){ return true; })