js中设置checkbox的设置

页面实例:

<div style='overflow-x: auto;'>
         <table cellspacing="0" cellpadding="0" border="1" class="table" >
             <thead>

             <th >
                 <div class="divbox" style="display:inline;">
                     <input class="cbox" type="checkbox" id="allChoose" checked="checked" />
                     <div class="cboxdiv cboxdivbg"></div>
                 </div>

                 选择
             </th>
             <th>序号</th>
             <th >商品小类数量</th>
             <th >提交审核原因</th>
             <th >申请人</th>
             <th>申请执行时间</th>
             <th>提交审核时间</th>
             <th>操作</th>
             </thead>
             <tbody>
<#if page??><!-- 列表展示开始 -->
                         <#list page.result as entry>
<tr>
                         <form class="tijiao" id="changeForm${entry_index+1!''}">
                             <input type="hidden" id="idStr" name="idStr" value="${entry.id!''}">
                             <td>
                                 <div class="divbox" style="display:inline;">
                                     <input class="cbox" type="checkbox" name="simChoose" checked="checked" value="${entry.id!''}"/>
                                     <div class="cboxdiv cboxdivbg"></div>
                                 </div>

                             </td>
                             <td>${entry_index+1!''}</td>
                             <td>${entry.smlClassNum!''}</td>
                             <td>${entry.submitAuditReason}</td>
                             <td>${entry.submitUser}</td>
                             <td>${entry.executeDate?datetime!''}</td>
                             <td>${entry.submitAuditDate?datetime!''}</td>
                             <td>
                                 <span class="set_but" style="color:#2298f3;cursor: pointer;" onclick="setButFunction(this)">查看</span>
                             </td>
                         </form>
                     </tr>
                         </#list>
                     </#if>
             <!-- 列表展示结束 -->
             </tbody>
         </table>
     </div>

<script type="text/javascript">

$("input[name='simChoose']").each(function(){
    $(this).bind('click',function(){
        if(!$(this).is(':checked')){
            $('#allChoose').removeAttr('checked');
            $('#allChoose').next().removeClass('cboxdivbg');
        }
        if($("input[name='simChoose']").length==$("input[name='simChoose']:checked").length){
            $('#allChoose').attr('checked','checked');
            $('#allChoose').next().addClass('cboxdivbg');
        }

</script >

猜你喜欢

转载自blog.csdn.net/qq_35872777/article/details/86690151
今日推荐