
- jQuery - Home
- jQuery - Roadmap
- jQuery - Overview
- jQuery - Basics
- jQuery - Syntax
- jQuery - Selectors
- jQuery - Events
- jQuery - Attributes
- jQuery - AJAX
- jQuery CSS Manipulation
- jQuery - CSS Classes
- jQuery - Dimensions
- jQuery - CSS Properties
- jQuery Traversing
- jQuery - Traversing
- jQuery - Traversing Ancestors
- jQuery - Traversing Descendants
- jQuery References
- jQuery - Selectors
- jQuery - Events
- jQuery - Effects
- jQuery - HTML/CSS
- jQuery - Traversing
- jQuery - Miscellaneous
- jQuery - Properties
- jQuery - Utilities
- jQuery Plugins
- jQuery - Plugins
- jQuery - PagePiling.js
- jQuery - Flickerplate.js
- jQuery - Multiscroll.js
- jQuery - Slidebar.js
- jQuery - Rowgrid.js
- jQuery - Alertify.js
- jQuery - Progressbar.js
- jQuery - Slideshow.js
- jQuery - Drawsvg.js
- jQuery - Tagsort.js
- jQuery - LogosDistort.js
- jQuery - Filer.js
- jQuery - Whatsnearby.js
- jQuery - Checkout.js
- jQuery - Blockrain.js
- jQuery - Producttour.js
- jQuery - Megadropdown.js
- jQuery - Weather.js
jQuery removeProp() Method
The removeProp() method in jQuery is used to remove properties from the set of matched elements.
If we want to remove HTML attributes like style, Id, or checked, we need to use the jQuery's removeAttr() method.
Syntax
Following is the syntax of removeProp() method in jQuery −
$(selector).removeProp(property)
Parameters
This method accepts the following parameter −
- property: The name of the property you want to remove.
Example
In the following example, we are using the removeProp() method to add and remove a custom property named "code" −
<html> <head> <style> img { padding: 10px; } div { color: red; font-size: 24px; } </style> <script src="https://code.jquery.com/jquery-3.7.0.js"></script> <script> $(document).ready(function(){ var para = $("p"); // Setting a custom property para.prop("code", 1234); // Appending the property value to the paragraph para.append("The secret code is: ", String(para.prop("code")), ". "); // Removing the custom property para.removeProp("code"); // Appending a message after removing the property para.append("Now the secret code is: ", String(para.prop("code")), ". "); }); </script> </head> <body> <p></p> </body> </html>
After the removeProp() method is executed, the code property will be removed and "undefined" will be returned.
jquery_ref_html.htm
Advertisements