Black friday

Save big!

All courses under $5 - for a limited time!

Code has been added to clipboard!

Make jQuery Remove Property by Using the removeProp Method

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

jQuery Remove Property: Main Tips

  • The jQuery .removeProp() removes properties added using the .prop() method.
  • Removing native properties of objects is not recommended: delete only custom ones. Set the native ones to false with .prop() instead.

Using .removeProp()

The .removeProp() method makes jQuery remove property added using .prop() on a selected element. In the example below, you can see jQuery remove CSS property from a <p> element:

Example
$("button").click(() => {
    $("p").prop("secret", "FF0000");
    $("p").removeProp("secret");
});

Follow this syntax to make jQuery remove property:

$("selector").removeProp(property);

The name of the property is always defined in a string.

Remember: do not make jQuery remove disabled, checked, selected, and other native properties. You won't be able to re-add them again.