removeProp() Method - Javascript jQuery Method and Property

Javascript examples for jQuery Method and Property:removeProp

Description

The removeProp() method removes a property set by the prop() method.

Syntax

Parameter Description
property Specifies the name of the property to remove

The following code shows how to Add and remove a property named "color":

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
    $("button").click(function(){
        var $x = $("div");
        $x.prop("color", "red");
        $x.append("color: " + $x.prop("color"));
        $x.removeProp("color");
        $x.append("<br>color: " + $x.prop("color"));
    });/*ww  w  .ja  v a  2  s.  c  o m*/
});
</script>
</head>
<body>

<button>Add and remove a property</button><br><br>

<div></div>

</body>
</html>

Related Tutorials