.removeProp()
Remove a property for the set of matched elements.
.removeProp(propertyName)🡢 jQuery
propertyName
| String | The 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