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().
Final published standard: Recommendation, Living Standard, Candidate Recommendation, or similar final form
Status in Chromium
Enabled by default
Consensus & Standardization
Last updated on 2020-11-09