<input value="text" /> <button>toggleAttribute("disabled")</button>Element: toggleAttribute() method / notebook
Element: toggleAttribute() method
Runnable notebook: every JavaScript, HTML and CSS example on this page executes in a sandboxed local frame. Nothing leaves the browser.
const button = document.querySelector("button");
const input = document.querySelector("input");
button.addEventListener("click", () => {
input.toggleAttribute("disabled");
});