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">
ただし、一部の Doctype では無効です。
まったく。これはステートフルな要素の良い解決策ですか? そうでない場合は、アドバイスをいただければ幸いです。
前もって感謝します。
HTML5 では、有効なdata-*属性を使用するオプションがあります。たとえば、この場合data-clicksはユーザー定義データを保存します。
data-*
data-clicks
参考文献:
Embedding custom non-visible data with the data attributes