English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

jQuery Miscellaneous removeData() Method

jQuery Miscellaneous Methods

The removeData() method will delete the previously useddata()Set by the data() methodData.

Using keyNameWhen called, removeData() will delete the specific value.

If removeData() is called without any parameters, it will delete all values.

Syntax:

$("selector").removeData(name)

Example

Remove previously attached data from the DIV element:

$("#btn1).click(function() {
  $("div").data("msg", "Hello World");
      alert("Message is: "); + $("div").data("msg");
});
$("#btn2).click(function() {
  $("div").removeData("msg");
      alert("Message is: "); + $("div").data("msg");
});
Test and see‹/›

Parameter Value

ParameterDescription
name(Optional) Specify the name of the data to be deleted
If no name is specified, this method will remove all stored data from the selected element

jQuery Miscellaneous Methods