checkbox、全选反选,获取值

<input id="Chk_All" onclick="CheckAll()" type="checkbox" />
<input name="al" id="" + item["WH"].ToString() + "" acttype="info"  type="checkbox" />

全选、反选

function CheckAll() {
  if ($("#Chk_All").attr("checked")) {
     //全选
    $("input[type='checkbox'][acttype='info']").attr("checked", "checked");
  } else {
    /取消全选
     $("input[type='checkbox'][acttype='info']").attr("checked", false);
     }
}

获取checkbox值:

方法一:

//获取全部
        function SelAllInfoId() {
            var json = "";
                
            $("input[type='checkbox'][acttype='info'][checked='checked']").each(function (index) {
                json = json + $(this).attr("id") + ";";
            });
}

方法二

//获取全部
function SelAllInfoId() {
  var json = "";
  if (json == "") {
    $('input[name="al"]:checked').each(function () {
     json = json + $(this).attr("id") + ";";
  });
}
原文地址:https://www.cnblogs.com/fjptwwf/p/6047326.html