Can I add arbitrary properties to DOM objects?

2020-01-30 06:36发布

Can I add arbitrary properties to JavaScript DOM objects, such as <INPUT> or <SELECT> elements? Or, if I cannot do that, is there a way to associate my own objects with page elements via a reference property?

7条回答
仙女界的扛把子
2楼-- · 2020-01-30 07:29

In case someone is wondering in 2015, yes, you can - and jQuery is doing just that in data. Just pick future-proof names like vendor prefixes or time-based random suffixes (jQuery).

查看更多
登录 后发表回答