checkbox全选,获取checkbox选中所有值

<table class="tbl_list">
                <thead>
                <tr>
                    <th width="4%">序列</th>
                    <th width="3%">
                        <input type="checkbox" id="AllSelectID" class="selectAll" name="AllSelect" value="" title="全选">
                    </th>
                    <th datatype="VARCHAR" width="5%">xxx</th>
                    <th datatype="VARCHAR" width="9%">啊啊</th>
                    <th datatype="VARCHAR" width="3.5%">啊啊</th>
                    <th datatype="VARCHAR" width="3.5%">啊啊</th>
                    <th datatype="VARCHAR" width="38%">啊啊</th>
                    <th datatype="VARCHAR" width="6%">啊啊</th>
                    <th datatype="VARCHAR" width="7%">啊啊</th>
                    <th datatype="VARCHAR" width="11%">啊啊</th>
                    <th datatype="VARCHAR" width="4%">啊啊</th>
                    <th datatype="VARCHAR" width="12%">啊啊</th>
                </tr>
                </thead>
                <tbody>
                    <#list billList as bill>
                        <tr>
                            <td width="4%" >${bill_index + 1}</td>
                            <td width="3%">
                                <input type="checkbox" id="selectAll" class="selectAll" name="all" value="${bill.oabiUuid!}">
                            </td>
                            <td datatype="VARCHAR" width="5%">${bill.oabiSuggestNumber!}</td>
                            <td datatype="VARCHAR" width="6%">${bill.oabiSuggestCategory!}-${bill.oabiSuggestCategoryno!}</td>
                            <td datatype="VARCHAR" width="3.5%">${bill.oabiBillFrequency!}</td>
                            <td datatype="VARCHAR" width="3.5%">${bill.oabiBillNum!}</td>
                            <td datatype="VARCHAR" width="35%" onclick="show('${bill.oabiUuid!}')" style="cursor: pointer;">${bill.oabiMeetingTitle!}</td>
                            <td datatype="VARCHAR" width="6%">${bill.oabiHeadername!}</td>
                            <td datatype="VARCHAR" width="7%">${bill.oabiOrgname!}</td>
                            <td datatype="VARCHAR" width="11%">${bill.oabiHostsName!}</td>
                            <td datatype="VARCHAR" width="5%">${bill.oabiSolveType!}</td>
                            <td datatype="VARCHAR" width="12%">${bill.oabiSatisfyLevel!}</td>
                        </tr>
                    </#list>
                </tbody>
            </table>

jQuery代码:

全选:

$('input[name="AllSelect"]').click(function(){  
            //alert(this.checked);  
            if($(this).is(':checked')){  
                $('input[name="all"]').each(function(){  
                    //此处如果用attr,会出现第三次失效的情况  
                    $(this).prop("checked",true);  
                });  
            }else{  
                $('input[name="all"]').each(function(){  
                        $(this).removeAttr("checked",false);  
                    });  
                    //$(this).removeAttr("checked");  
            }  
                  
        }); 

获取checkbox选中的value

function checks(){
        var result = "";
          $('input:checkbox[name="all"]:checked').each(function(i){
           if(0==i){
               result = $(this).val();
           }else{
               result += (","+$(this).val());
           }
          });
         return result;
    }

 

posted @ 2018-01-18 09:50  西湖看雪  阅读(266)  评论(0)    收藏  举报