🚨 Time is Running Out: Reserve Your Spot in the Lucky Draw & Claim Rewards! START NOW

Code has been added to clipboard!

jQuery .prop(): Set or Get Element Properties and Values

Reading time 1 min
Published Jan 22, 2018
Updated Oct 1, 2019

jQuery prop: Main Tips

  • jQuery .prop() method returns the property value of the first matched element.
  • .prop() jQuery can also set properties for elements.
  • To remove the properties set with this method, use jQuery .removeProp().

Using .prop()

The jQuery .prop() function gets or sets the property value of the selected element. The function returns undefined if the value for a property is not assigned.

In the example, clicking a button changes the property value of checkboxes:

$("button").click(() => {
        disabled: false

Tip: you can get values of each element by using .each() or .map() functions.

Follow this jQuery .prop() syntax to return the specified property's value:


Note: the property is defined by a string.

Now this syntax is used to set a value for one property:

$("selector").prop(property, newValue);

You can also add a function returning the value needed as the newValue.

To set values for multiple elements using .prop() jQuery method, put them in pairs:

$("selector").prop(property:value, property:value, ...);

Note: use .prop()) in jQuery to set tagName, nodeType, selectedIndex, nodeType, etc. They cannot be set with .attr() since jQuery 1.6.