The removeProp method
The removeProp
method removes properties from elements. Note: use this method to remove artificially introduced properties, do not remove native properties of elements (i.e. the original, native properties of elements), this may cause browser errors. In particular, do not use removeProp
to remove attributes such as checked
and disabled
. When these attributes are missing from input
elements, their properties of the same name cease to exist, they simply take the value false
. So, to disable these properties, you need to set them to false
using the prop
method.
Syntax
$(selector).removeProp(property name);
Example
Let's set the text
property to aaa
on the paragraph and output it in the paragraph text:
<p></p>
elem = $('p');
elem.prop('text', 'aaa').html(elem.prop('text'));
HTML the code will look like this:
<p>aaa</p>
Let's now remove this property:
<p></p>
elem = $('p');
elem
.prop('text', 'aaa')
.html(elem.prop('text'))
.removeProp('text')
.html(elem.prop('text'));
See also
-
method
prop
,
which allows you to work with the properties of elements -
method
removeAttr
,
which allows you to remove attributes from elements -
method
attr
,
which allows you to work with element attributes