jQuery

Instance; event; performance; mobile; foundation

remove

英[r??mu:v]美[r??muv]

vt.Remove; expel; take off, take off; move

vi.Migrate, move; leave

n.Distance, gap; move

data

English [?de?t?] American [?det?, ?d?t?, ?dɑt?]

n. Information, material; plural of datum; [computer] data , data; value extracted from scientific experiments

jquery jQuery.removeData() method syntax

Function: removeData() method deletes the data previously set through the data() method. This is a low-level method; using .removeData() is more convenient.

Syntax: $(selector).removeData(name)

Parameters:

ParameterDescription
name Optional. Specifies 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 jQuery.removeData() method example

<html>
<head>
<script type="text/javascript" src="http://apps.bdimg.com/libs/jquery/2.1.1/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
  $("#btn1").click(function(){
    $("div").data("greeting", "Hello World");
    alert("Greeting is: " + $("div").data("greeting"));
  });
  $("#btn2").click(function(){
    $("div").removeData("greeting");
    alert("Greeting is: " + $("div").data("greeting"));
  });
});
</script>
</head>
<body>
<button id="btn1">向 div 元素添加數(shù)據(jù)</button><br />
<button id="btn2">從 div 元素刪除數(shù)據(jù)</button>
<div></div>
</body>
</html>
Run instance ?

Click the "Run instance" button to view the online instance