HTMLElement.dataset

<div id=“user” dataid=“1234567890” datauser=“johndoe” datadateofbirth>John Doe

<span class="token operator"><</span><span class="token operator">/</span>div<span class="token operator">></span>

<span class="token keyword">var</span> el <span class="token operator">=</span> document<span class="token punctuation">.</span><span class="token function">querySelector<span class="token punctuation">(</span></span><span class="token string">'#user'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">
// el.id == 'user'
</span><span class="token comment" spellcheck="true">// el.dataset.id === '1234567890'
</span><span class="token comment" spellcheck="true">// el.dataset.user === 'johndoe'
</span><span class="token comment" spellcheck="true">// el.dataset.dateOfBirth === ''
</span>
el<span class="token punctuation">.</span>dataset<span class="token punctuation">.</span>dateOfBirth <span class="token operator">=</span> <span class="token string">'1960-10-03'</span><span class="token punctuation">;</span><span class="token comment" spellcheck="true"> // set the DOB.</span>