Absolutely! jQuery .data() .
$('#someId').data('myData', someValue); // To store the data $('#someId').data('myData'); // To retrieve it again
Any JavaScript variable can be stored as data - it is not limited to strings.
Note that this does not actually attach the data to the DOM node, as you say (which should be avoided). jQuery stores its own cache of all the data and DOM nodes you store to which you want to connect them. So this is not the same as domNode.myData = someValue .
David tang
source share