Jquery 如何在创建表时基于值选中或取消选中复选框

Jquery 如何在创建表时基于值选中或取消选中复选框,jquery,Jquery,我正在根据从服务器收到的响应显示记录 基于appUserID的值,我希望选中复选框或取消选中 appUserID有两个值1和0 如果为1,则复选框应选中,否则复选框应未选中 你能告诉我怎么做吗 这是我的密码 var response = [ { "phone": "2345678909", "appUserTypeID": "1", "email": "we@gmail.comj", "depotName": "WEQW",

我正在根据从服务器收到的响应显示记录

基于appUserID的值,我希望选中复选框取消选中

appUserID有两个值1和0

如果为1,则复选框应选中,否则复选框应未选中

你能告诉我怎么做吗

这是我的密码

var response = [
    {
        "phone": "2345678909",
        "appUserTypeID": "1",
        "email": "we@gmail.comj",
        "depotName": "WEQW",
        "depotID": "22",
        "appUserID": "1",
        "webEnabled": "1",
        "password": "137424",
        "appUserName": "ESSS",
        "emp_ID": "1243"
    },
    {
        "phone": "9098888888",
        "appUserTypeID": "1",
        "email": "kiran@gmail.com",
        "depotName": "Depot4",
        "depotID": "17",
        "appUserID": "0",
        "webEnabled": "1",
        "password": "783652",
        "appUserName": "Mike",
        "emp_ID": "1245"
    }
];

    var html = '';

    for(var i=0;i<response.length;i++)
    {

        var emp_id= response[i].emp_ID.trim();
        var emp_name= response[i].appUserName.trim();
        var emp_phone= response[i].phone.trim();
        var emp_email= response[i].email.trim();
        var emp_depotName= response[i].depotName.trim();
        var emp_depotID = response[i].depotID.trim();
        var appUserID = response[i].appUserID.trim();


                    html += '<tr>\
                            <td class="text-center"><input type="checkbox" checked  appUserID="'+appUserID+'"  id="'+emp_id+'"/><label for="'+emp_id+'" class="marg_none"><div></div></label></td>\n\
                            <td>'+emp_id+'</td>\n\
                            <td>'+emp_name+'</td>\n\
                            <td>'+emp_phone+'</td>\n\
                            <td>'+emp_email+'</td>\n\
                            <td>'+emp_depotName+'</td>\n\
                            <td><a data-depotid="'+emp_depotID+'" class="label label-success edit">Edit</a></td>\n\
                        </tr>';

    }

    $("#managementtablebody").html(html);
var响应=[
{
“电话”:“2345678909”,
“appUserTypeID”:“1”,
“电子邮件”:we@gmail.comj",
“仓库名称”:“WEQW”,
“depotID”:“22”,
“appUserID”:“1”,
“webEnabled”:“1”,
“密码”:“137424”,
“appUserName”:“ESSS”,
“emp_ID”:“1243”
},
{
“电话”:“909888888”,
“appUserTypeID”:“1”,
“电子邮件”:kiran@gmail.com",
“depotName”:“Depot4”,
“depotID”:“17”,
“appUserID”:“0”,
“webEnabled”:“1”,
“密码”:“783652”,
“appUserName”:“Mike”,
“emp_ID”:“1245”
}
];
var html='';

对于(var i=0;i,根据条件添加选中的属性

<td class="text-center"><input type="checkbox" ' + (appUserID == 1 ? 'checked' : '') + ' appUserID="' + appUserID + '"  id="' + emp_id + '"/><label for="' + emp_id + '" class="marg_none"><div></div></label></td>\n\
\n\

演示:

非常感谢。