🔸attribute
🚧 under construction
🔰 JS ⟩ browser ⟩ DOM ⟩ types ⟩ Element ⟩ attribute
🚧
HTML attributes are not case sensitive, but JavaScript property names are.
convert HTML attribute name to JS property name:
HTML attribute JS property
--------------------------------------------
data-first-name="" elem.dataset.firstName // "data-" attributeexceptions
HTML attribute JS property
--------------------------------------------
class="" elem.className, elem.classList
for="" label.htmlFor
value="" input.defaultValue // `input.value`: user's current input
--------------------------------------------Element ⟩
.classList (DOMTokenList) - can add(), remove(), contains(), toggle() ...
HTMLElement ⟩
Last updated
Was this helpful?