⚖️attributes vs. properties
HTML attributes vs. DOM properties
🔸 HTML attributes ┊ DOM properties┊ attr-prop sync ┊
HTML attributes
DOM properties
DOM properties are NOT always strings. for example:
input.checked (boolean)
div.style (CSSStyleDeclaration)
a.href is always a full URL. ( 👉🏻 See: 💈範例 )
property ⇔ attribute sync
standard attribute changes ⇒ auto-update property, and vice versa.
⭐️ with some exceptions ( 👉🏻 💈範例 )
Last updated
Was this helpful?