Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我已经看到了一些在元素属性中存储一些状态或数据的工具:
<div clicks="2" id="myDiv" class="some-class">
但在某些文档类型中无效。
完全没有。这是有状态元素的好解决方案吗?如果没有,一些建议将不胜感激。
提前致谢。
在 HTML5 下,您可以选择使用有效的data-*属性,例如在本例data-clicks中用于存储用户定义的数据。
data-*
data-clicks
参考:
Embedding custom non-visible data with the data attributes