
- 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 Misc removeData() Method
The jQuery removeData() method is used to remove data that was previously set using the data() method.
Syntax
$(selector).removeData(name)
Parameters
Here is the description of the above syntax −
- name (optional): The name of the data to remove. If omitted, all data associated with the elements will be removed.
Example
In the following example, we are using the jQuery Misc removeData() method to remove previously attached data from a <div> element −
<html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.7.1/jquery.min.js"></script> <script> $(document).ready(function(){ $("#saveData").click(function(){ $("#info").data("username", "Tutorialspoint"); alert("Username saved: " + $("#info").data("username")); }); $("#clearData").click(function(){ $("#info").removeData("username"); alert("Username after removal: " + $("#info").data("username")); }); }); </script> </head> <body> <button id="saveData">Save Username</button><br> <button id="clearData">Clear Username</button> <p id="info"></p> </body> </html>
After executing, click the above buttons "save" and "clear" buttons.
jquery_ref_miscellaneous.htm
Advertisements