jquery checkbox不可选怎么实现

来自:互联网
时间:2021-02-07
阅读:

jquery如何让checkbox不可选?

在jquery中,想让checkbox不可选,就需要禁用checkbox(复选框),给checkbox添加disabled属性即可。

示例:

$("input[type=checkbox]").each(function () {
        $(this).attr("disabled", false);
});

那么禁用的checkbox,如何启用尼?

JQuery禁用或者启动checkbox的代码

function changeCheckboxState(lx){
            if(true){//禁用
                $("input[type=checkbox]").each(function(){
                    $(this).attr("disabled",true);
                });
            }else{//启用
                $("input[type=checkbox]").each(function(){
                    $(this).attr("disabled",false);
                });
            }
        }
返回顶部
顶部