[英]How can we disable the checkbox when user check the one of checbox in the Checkboxlist?
I've a table in which first row contains a checkbox list. 我有一个表,其中第一行包含一个复选框列表。 I've a scenario like if user click any checkbox of that list the other should be disabled mode and uncheck the checkbox enable the all checkboxes. 我有一种情况,例如,如果用户单击该列表中的任何复选框,其他应禁用模式,然后取消选中该复选框,则启用所有复选框。
I've tried like to disable the checkbox ,but unable to un-checkbox the checkbox it should to enable all. 我试图禁用该复选框,但无法取消选中该复选框以启用所有功能。
var $checkboxList = $('#tr1 input[type=checkbox]');
$checkboxList.change(function () {
$checkboxList.each(function () {
if (!this.checked) {
this.disabled = true;
}
else {
this.disabled = false;
}
});
});
how can we hold the state of checkboxes in case of paging ? 在分页的情况下,如何保持复选框的状态?
In answer to your first question, you can just set .prop('disabled')
based on the value of this.checked
: 在回答第一个问题,你可以设置.prop('disabled')
基础上的价值this.checked
:
$checkboxList.change(function () {
$checkboxList.not(this).prop('disabled', this.checked);
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.