How to enable button when checkbox clicked in jQuery?
You can do it like this:
$("#checkBoxID").click(function() { $("#buttonID").attr("disabled", !this.checked); });
This enables when checked, and disables again if you uncheck. In jQuery .attr("disabled", bool)
takes a boolean, so you can keep this pretty short using the this.checked
DOM property of the checkbox.
$("#yourcheckboxid").click(function() { var checked_status = this.checked; if (checked_status == true) { $("#yourbuttonid").removeAttr("disabled"); } else { $("#yourbuttonid").attr("disabled", "disabled"); } });
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With