.removeProp()

Remove a property for the set of matched elements.

.removeProp(propertyName)🡢 jQuery

propertyName StringThe name of the property to remove.

The .removeProp() method removes properties set by the .prop() method.

Note:This method should not be used to remove built-in (native) properties such as "checked", "disabled", "selected", or others. This can lead to unexpected behavior.

It's almost always better to use .prop() to set native properties to false instead of removing them.

Set a numeric property on a paragraph and then remove it.

JS
<p></p>
CSS
img {
  padding: 10px;
}
div {
  color: red;
  font-size: 24px;
}
HTML
para = $("p");
para
  .prop("luggageCode", 1234)
  .append(
    "The secret luggage code is: ",
    String(para.prop("luggageCode")),
    ". "
  )
  .removeProp("luggageCode")
  .append(
    "Now the secret luggage code is: ",
    String(para.prop("luggageCode")),
    ". "
  );
DEMO

Looking for a Web Developer?

👋

Hi! I'm Basti, author of this site. If you are looking for a web developer with 15+ years of experience, holla at me!

Be it the good 'ol jQuery, vanilla JS or modern frameworks like Vue and Svelte, front- or backend, I can help you.

Just write me at jobs@jqapi.com :)