KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
Is it ok to set custom properties on DOM elements, and rely on them persisting? For example, given <html><body><div id="foo"></div></body></html> Would it be fair to do document.getElementById('foo').bar = "baz"; , and expect document.getElementsByTagName('div')[0].bar to equal "baz" ? Note that I'm talking about properties as in normal javascript object properties here, not element attributes. I'm interested both in how cross-browser it is, and whether its supported in any spec. Does the DOM API guarantee that the same javascript object will be returned for the same DOM element every time?
Tags (comma-separated)
Save Edits
Cancel