<p>
<label>
<input id="check-box" name="b" value="1" type="checkbox" disabled /> Check
this box!
</label>
</p>
<p>
<label>
<input id="toggle-box" name="b" value="2" type="checkbox" /> Enable the
other checkbox.
</label>
</p>HTMLInputElement: disabled property / notebook
HTMLInputElement: disabled property
Runnable notebook: every JavaScript, HTML and CSS example on this page executes in a sandboxed local frame. Nothing leaves the browser.
const checkBox = document.getElementById("check-box");
const toggleBox = document.getElementById("toggle-box");
toggleBox.addEventListener("change", (event) => {
checkBox.disabled = !event.target.checked;
});