Use the buttons to change the checkbox’s disabled property.
Checkbox is enabled.
const checkbox = document.getElementById("ck1");
document.getElementById("disableButton").addEventListener("click", () => {
checkbox.disabled = true;
});
document.getElementById("enableButton").addEventListener("click", () => {
checkbox.disabled = false;
});
Enable/disable checkbox tutorial
Author & Instructor at plus2net
I write and maintain practical tutorials on Python, PHP, SQL, JavaScript, HTML, jQuery, and web development at plus2net. The tutorials focus on clear explanations, working examples, and code that readers can test and adapt while learning.