jquery-mobile/experiments/api-viewer/docs/jQuery.removeData/index.html
2010-11-01 21:46:29 -04:00

61 lines
No EOL
2.8 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>jQuery.removeData()</h1>
</div>
<div data-role="content" data-theme="c" id="jQuery.removeData1">
<h2 class="jq-clearfix roundTop section-title">
<span class="name">jQuery.removeData( element, [ 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="jQuery.removeData-element-name">
<h4 class="name">
<span class="versionAdded">version added: <a href="/category/version/1.2.3/">1.2.3</a></span>jQuery.removeData( element, [ name ] )</h4>
<p class="arguement"><strong>element</strong>A DOM element from which to remove data.</p>
<p class="arguement"><strong>name</strong>A string naming the piece of data to remove.</p>
</li></ul>
<div class="longdesc">
<p><strong>Note:</strong> This is a low-level method, you should probably use <code><a href="/removeData">.removeData()</a></code> instead.</p>
<p>The <code>jQuery.removeData()</code> method allows us to remove values that were previously set using <code><a href="/jQuery.data">jQuery.data()</a></code>. When called with the name of a key, <code>jQuery.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">&lt;!DOCTYPE html&gt;
&lt;html&gt;
&lt;head&gt;
&lt;style&gt;
div { margin:2px; color:blue; }
span { color:red; }
&lt;/style&gt;
&lt;script src="http://code.jquery.com/jquery-latest.js"&gt;&lt;/script&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;div&gt;value1 before creation: &lt;span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;value1 after creation: &lt;span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;value1 after removal: &lt;span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;value2 after removal: &lt;span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;script&gt;
var div = $("div")[0];
$("span:eq(0)").text("" + $("div").data("test1"));
jQuery.data(div, "test1", "VALUE-1");
jQuery.data(div, "test2", "VALUE-2");
$("span:eq(1)").text("" + jQuery.data(div, "test1"));
jQuery.removeData(div, "test1");
$("span:eq(2)").text("" + jQuery.data(div, "test1"));
$("span:eq(3)").text("" + jQuery.data(div, "test2"));&lt;/script&gt;
&lt;/body&gt;
&lt;/html&gt;</code></pre>
<h4>Demo:</h4>
<div class="demo code-demo"></div>
</div></div>
</div>
</div>
</div>
</body></html>