<spanclass="versionAdded">version added: <ahref="/category/version/1.2.3/">1.2.3</a></span>jQuery.data( element, key, value )</h4>
<pclass="arguement"><strong>element</strong>The DOM element to associate with the data.</p>
<pclass="arguement"><strong>key</strong>A string naming the piece of data to set.</p>
<pclass="arguement"><strong>value</strong>The new data value.</p>
</li></ul>
<divclass="longdesc">
<p><strong>Note:</strong> This is a low-level method; you should probably use <code><ahref="/data">.data()</a></code> instead.</p>
<p>The <code>jQuery.data()</code> method allows us to attach data of any type to DOM elements in a way that is safe from circular references and therefore from memory leaks. We can set several distinct values for a single element and retrieve them later:</p>
<pclass="desc"><strong>Description: </strong>Returns value at named data store for the element, as set by jQuery.data(element, name, value), or the full data store for the element.</p>
<pclass="arguement"><strong>element</strong>The DOM element to query for the data.</p>
<pclass="arguement"><strong>key</strong>Name of the data stored.</p>
</li>
<liclass="signature"id="jQuery.data-element">
<h4class="name">
<spanclass="versionAdded">version added: <ahref="/category/version/1.4/">1.4</a></span>jQuery.data( element )</h4>
<pclass="arguement"><strong>element</strong>The DOM element to query for the data.</p>
</li>
</ul>
<divclass="longdesc">
<p><strong>Note:</strong> This is a low-level method; you should probably use <code><ahref="/data">.data()</a></code> instead.</p>
<p>The <code>jQuery.data()</code> method allows us to attach data of any type to DOM elements in a way that is safe from circular references and therefore from memory leaks. We can retrieve several distinct values for a single element one at a time, or as a set:</p>
<pre>alert(jQuery.data( document.body, 'foo' );
alert(jQuery.data( document.body ));</pre>
<p>The above lines alert the data values that were set on the <code>body</code> element. If nothing was set on that element, an empty string is returned.</p>
<p>Calling <code>jQuery.data(element)</code> retrieves all of the element's associated values as a JavaScript object. Note that jQuery itself uses this method to store data for internal use, such as event handlers, so do not assume that it contains only data that your own code has stored.</p>