Skip to main content
added 289 characters in body
Source Link
André Laszlo
  • 15.6k
  • 3
  • 68
  • 83

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.

I would use the jQuery.data method:

// attach ('foo', 52) to the key/value store for the document.body element
jQuery.data(document.body, 'foo', 52);

I would use the jQuery.data method:

// attach ('foo', 52) to the key/value store for the document.body element
jQuery.data($('#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.

Source Link
André Laszlo
  • 15.6k
  • 3
  • 68
  • 83

I would use the jQuery.data method:

// attach ('foo', 52) to the key/value store for the document.body element
jQuery.data(document.body, 'foo', 52);