I would use the jQuery.data method:
// attach ('foo', 52) to the key/value store for the document.body element
jQuery.data(document.body$('#id_of_your_element'), 'foo', 52);
The problems with your method, at least the way I see it, is that it is not valid xhtml. And why would that matter? Basically, you don't know exactly how a browser would handle your invalid attributes - it might just strip them off the dom node or something else completely.