jQuery Tutorial Tutorials - jQuery .removeProp() method

jQuery .removeProp() method

The .removeProp() method in jQuery is used to remove a proprerty for the set of matched elements.

jQuery .removeProp() method Syntax

.removeProp(propertyName)

propertyName: The name of the property to remove.

jQuery .removeProp() method Examples

In this example, we will set a numeric property on a paragraph and then remove it.

<p> </p>
<script>
    var $para = $("p");
    $para.prop("luggageCode", 1234);
    $para.append("The secret luggage code is: ", String($para.prop("luggageCode")), ". ");
    $para.removeProp("luggageCode");
    $para.append("Now the secret luggage code is: ", String($para.prop("luggageCode")), ". ");

    //The secret luggage code is: 1234. Now the secret luggage code is: undefined. 
</script>

Try it

Date:2019-08-19 15:46:10 From:www.Lautturi.com author:Lautturi