如何取消选中已禁用的复选框 [英] How to uncheck a disabled checkbox

查看:246
本文介绍了如何取消选中已禁用的复选框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我有一个动态jquery数据表,它有复选框。如果在标题处选中了复选框,则还会检查行中的所有复选框。我有一些禁用的行。当选中check all选项时,我不希望选中disabled复选框。下面是检查和取消选中所有文本框的代码



我尝试过:



Hi,

I have a dynamic jquery data table which has check boxes it. when a check box is checked at header all the check boxes in rows are also checked. i have some rows which are disabled. when the check all option is checked i don't want the disabled checkbox to be checked. Below is the code to check and uncheck all the textboxes

What I have tried:

function CheckUncheckAll() {
         $("#table thead ").on("click", 'input[type="checkbox"]', function () {
             if (!this.disabled) {
                 $('#table tbody chktransid').prop("checked", false);
             }
             if (this.checked) {

                 $('#table tbody input[type="checkbox"]').prop("checked", true);
             } else {
                 $('#table tbody input[type="checkbox"]').removeAttr("checked");
             }
         });

推荐答案

#table thead)。on( click ' input [type =checkbox]' function (){
if (!this.disabled){
("#table thead ").on("click", 'input[type="checkbox"]', function () { if (!this.disabled) {


' #table tbody chktransid')。prop( 选中 false );
}
if this .checked){
('#table tbody chktransid').prop("checked", false); } if (this.checked) {


' #table tbody input [type =checkbox]')。prop( 选中 true );
} 其他 {
('#table tbody input[type="checkbox"]').prop("checked", true); } else {


这篇关于如何取消选中已禁用的复选框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆