can.data
Associate data with or retrieve data from DOM nodes.
can.data(nodeList, key, value)
Parameters
-
nodeList
{NodeList}
The list of nodes to add this data to.
-
key
{String}
The key to store this data under.
-
value
{*}
The data to store.
can.data(nodeList, key)
Parameters
-
nodeList
{NodeList}
The list of nodes data was stored under.
-
key
{String}
The key to retrieve.
Returns
{*}
The data stored under key.
can.data
enables the associatation of arbitrary data with DOM nodes and JavaScript objects.Setting Data
can.data( can.$('#elm'), key, value )
Accessing Data
can.data( can.$('#elm'), key )
Due to the way browsers security restrictions with plugins and external code, the data method cannot be used on
object
(unless it's a Flash plugin),applet
orembed
elements.