I Have a CheckBox with id "CB" and a Button with id "BT" . I want to validate :
so how the right script if inner this the Jquery ?
var CB = $("#CB");
var inital_CB = CB .is(":checked");
var BT= $("#BT").attr("disabled", !inital_CB);
CB .click(function() {
BT.attr("disabled", !this.checked);
});
If all your wanting to do is to trigger some code depending on if the checkbox is selected or not, here you go:
var theButton = document.getElementById("Button1");
var theCheckBox = document.getElementById("Checkbox1");
theButton.onclick = function () {
if (theCheckBox.checked) {
//Code that executes when checkbox is selected
}
else {
//Code that executes when checkbox is not selected
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.