zoukankan      html  css  js  c++  java
  • layui实现复选框全选,反选

    html

    <div class="layui-input-inline">
                     <input type="checkbox" class="checkboxAll" lay-skin="primary"  lay-filter="allChoose" title='全选'>
               </div>
    <input type="checkbox" name="check[]" value="{$item.id}" lay-skin="primary" title="{$item.type_name}" lay-filter="oneChoose">
    <input type="button" id="sub" class="layui-btn" value="确认添加">

    js

    layui.use(['layer','form'], function () {
            var form = layui.form
            ,layer = layui.layer;
    
    
          form.on('checkbox(allChoose)', function (data) {
            $("input[name='check[]']").each(function () {
                this.checked = data.elem.checked;
                // console.log(data);
            });
            form.render('checkbox');
          });
    
        }); 
    
        $('#sub').click(function(){
          var items =[];
          $("input[name='check[]']:checked").each(  
            function(){  
              items.push($(this).val());
            }) 
          console.log(items);
        })

  • 相关阅读:
    poj 1634
    poj 2153
    POJ 1693
    poj 1789
    POJ 2676
    vue 路由
    用 node.js 创建第一个Hello World
    js原生Ajax 的封装和原理
    BFC原理
    怎么理解js的面向对象编程
  • 原文地址:https://www.cnblogs.com/zxf100/p/9523942.html
Copyright © 2011-2022 走看看