jquery jQuery.removeData() method


  Translation results:

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() methodsyntax

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() methodexample

<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 元素添加数据</button><br />
<button id="btn2">从 div 元素删除数据</button>
<div></div>
</body>
</html>
Run instance »

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

Popular Recommendations

Home

Videos

Q&A