A new method named Element.toggleAttribute() allows toggling the existence of an element’s attribute in a way similar to Element.classList.toggle. An optional force parameter forces toggling the attribute even if it doesn't exist. This makes managing boolean attributes much simpler as the interface doesn't use strings as does Element.setAttribute().
Specification
Status in Chromium
Enabled by default (tracking bug) in:
- Chrome for desktop release 69
Consensus & Standardization
After a feature ships in Chrome, the values listed here are not guaranteed to be up to date.
- In development
- Positive
- No signal
- Positive
Owner
Last updated on 2020-11-09