mirror of
https://github.com/Hopiu/jquery-mobile.git
synced 2026-03-17 14:30:28 +00:00
60 lines
No EOL
2.5 KiB
HTML
60 lines
No EOL
2.5 KiB
HTML
<!DOCTYPE html>
|
|
<html lang='en'><head>
|
|
<meta charset="utf-8" /><meta http-equiv='content-type' content='text/html; charset=UTF-8' /></head><body>
|
|
<div data-role="page">
|
|
<div data-role="header">
|
|
<h1>.removeData()</h1>
|
|
|
|
</div>
|
|
<div data-role="content" data-theme="c" id="removeData1">
|
|
<h2 class="jq-clearfix roundTop section-title">
|
|
<span class="name">.removeData( [ name ] )</span> <span class="returns">Returns: <a class="return" href="http://docs.jquery.com/Types#jQuery">jQuery</a></span>
|
|
</h2>
|
|
<div class=" entry-details">
|
|
<p class="desc"><strong>Description: </strong>Remove a previously-stored piece of data.</p>
|
|
<ul class="signatures"><li class="signature" id="removeData-name">
|
|
<h4 class="name">
|
|
<span class="versionAdded">version added: <a href="/category/version/1.2.3/">1.2.3</a></span>.removeData( [ name ] )</h4>
|
|
<p class="arguement"><strong>name</strong>A string naming the piece of data to delete.</p>
|
|
</li></ul>
|
|
<div class="longdesc"><p>The <code>.removeData()</code> method allows us to remove values that were previously set using <code>.data()</code>. When called with the name of a key, <code>.removeData()</code> deletes that particular value; when called with no arguments, all values are removed.</p></div>
|
|
<h3>Example:</h3>
|
|
<div id="entry-examples" class="entry-examples"><div id="example-0">
|
|
<h4><span class="desc">Set a data store for 2 names then remove one of them.</span></h4>
|
|
<pre><code class="example demo-code"><!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<style>
|
|
div { margin:2px; color:blue; }
|
|
span { color:red; }
|
|
</style>
|
|
<script src="http://code.jquery.com/jquery-latest.js"></script>
|
|
</head>
|
|
<body>
|
|
<div>value1 before creation: <span></span></div>
|
|
<div>value1 after creation: <span></span></div>
|
|
<div>value1 after removal: <span></span></div>
|
|
|
|
<div>value2 after removal: <span></span></div>
|
|
<script>
|
|
|
|
$("span:eq(0)").text("" + $("div").data("test1"));
|
|
$("div").data("test1", "VALUE-1");
|
|
$("div").data("test2", "VALUE-2");
|
|
$("span:eq(1)").text("" + $("div").data("test1"));
|
|
$("div").removeData("test1");
|
|
$("span:eq(2)").text("" + $("div").data("test1"));
|
|
$("span:eq(3)").text("" + $("div").data("test2"));
|
|
|
|
</script>
|
|
</body>
|
|
</html></code></pre>
|
|
<h4>Demo:</h4>
|
|
<div class="demo code-demo"></div>
|
|
</div></div>
|
|
</div>
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</body></html> |