domData.get
Get data that was stored in a DOM Node using the specified key
.
domData.get(node, key)
Parameters
- node
{Node}
:The element.
- key
{String}
:The property to retrieve from the element’s data.
Returns
{*}
:
value The value stored for the key.
Use
import domData from "can-dom-data";
const element = document.createElement("p");
document.body.appendChild(element);
domData.set(element, "metadata", {
hello: "world"
});
let metadata = domData.get(element, "metadata");
// metadata is {hello: "world"}