更新时间:2023-09-11 21:27:22
$(函数(){
$('#id_of_your_checkbox')。点击(函数(){
如果($(本)。是(':检查')){
$('#id_of_your_button')ATTR(禁用,禁用)。
}其他{
$('#id_of_your_button')removeAttr(禁用)。
}
});
});
和这里的现场演示。
I want something like this but with a slight change. I want a Button to be enabled or disabled on Checkbox checked event, i.e. when checkbox is checked then and then only button should be enabled otherwise it is disabled. This should be done using jQuery Code not JavaScript.
As this is MVC form so there is no Form ID.
$(function() {
$('#id_of_your_checkbox').click(function() {
if ($(this).is(':checked')) {
$('#id_of_your_button').attr('disabled', 'disabled');
} else {
$('#id_of_your_button').removeAttr('disabled');
}
});
});
And here's a live demo.