jQuery MiscellaneousremoveData()Method

jQuery 杂项方法jQuery Miscellaneous Methods

Example

Remove previously attached data from the <div> element:

$("#btn2").click(function(){
$("div").removeData("greeting");
alert("Greeting is: " + $("div").data("greeting"));
});

Try it yourself »

Definition and Usage

The removeData() method removes the data set previously through thedata()method.


Syntax

$(selector).removeData(name)

Parameters Description
name Optional. Specifies the name of the data to remove.
If no name is specified, the method will remove all stored data from the selected elements.


jQuery 杂项方法jQuery Miscellaneous Methods

Other Extensions