datatable的全选和单个复选框

<table id="device-all-table" class="m-table t-striped table-hide">
																<thead>
																	<tr>
																		<th class="" style="width: 5%;">
																		    <label for="checkbox30" class="m-checkbox widthAu f-ib ">
																		        <input type="checkbox" name="box" class="weui-check weui " id="checkbox30">
																		        <i class="weui-icon-checked"></i>
																		    </label>
																		</th>
																		<th class="txt-hide" title="计算机名" style="width: 20%;">计算机名</th>
																	</tr>
																</thead>
																<tbody>
																	<tr>
																		<td></td>
																		<td class="">
																		    <label for="checkbox31" class="m-checkbox widthAu f-ib ">
																		        <input type="checkbox" name="box" class="weui-check " id="checkbox31">
																		        <i class="weui-icon-checked"></i>
																		    </label>
																		</td>
																		<td>
																			 <a data-href="mnt-treeNode5.html"> WIN-7NBP3CTR1UM</a>
																		</td>
																	</tr>
																</tbody>
															</table>
//全选
	$(".weui").click(function () {
		   
	    if (this.checked) {
	    $(this).attr('checked', 'checked')
	    $("input[name='box']").each(function () {
	    this.checked = true;
	       if($(this).attr("id")!="checkbox30"){
			console.log($(this).attr("id"));
			}
	  });
	
	} else {
	    $(this).removeAttr('checked')
	    $("input[name='box']").each(function () {
	    this.checked = false;
	    });
	  }
	});
	//单个
	$("input[name='box']").click(function () {
	  if ($(this).is(":checked") == false) {
	    $(".weui").prop("checked", false);
	  } else {
	    var flag = true;
	    $(".weui").prop("checked", true);
	    $("input[name='box']").each(function () {
	    if (this.checked == false) {
	      $(".weui").prop("checked", false);
	      flag = false;
	      return;
	    }
	      if($(this).attr("id")!="checkbox30"){
	      			console.log($(this).attr("id"));
	      	}
	  });
	}
	});
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值