JS获取CHECKBOX的值 AND 两个CHECKBOX 循环选中

  1. 获取多选按钮的值
   var chk_value = '';
   $('input[data-action="checkRole"]:checked').each(function(){
   chk_value += ($(this).parent('div').attr('data-id'))+',';
   });

  2. 两个checkbox 循环选中 两个循环时,可先定义一个变量flag

  <% var flag = false;
      for (var m = 0;m < list1.length; m++) {
        if (list1[m].authorityId == list[i].authorityId){
             flag = true;
          }
        } %>
        <% if (flag) {   %>
        <input type="checkbox" checked style="width: 18px;height: 14px;" data-action="checkRole">
        <% } else { %>
        <input type="checkbox"  style="width: 18px;height: 14px;" data-action="checkRole">
   <% }%>

猜你喜欢

转载自www.cnblogs.com/myfighting/p/12377060.html