• input全选和取消全选


    <!DOCTYPE html>
    <html>
    <head>
    <meta charset="utf-8" />
    <title>jQuery实现复选框的全选和全不选</title>
    </head>
    <body>
    <label><input type="checkbox" name="checkall" />全选</label>
    <br><br>
    <label><input type="checkbox" name="checkbox" />复选框1</label>
    <label><input type="checkbox" name="checkbox" />复选框2</label>
    <label><input type="checkbox" name="checkbox" />复选框3</label>
    <label><input type="checkbox" name="checkbox" />复选框4</label>
    <label><input type="checkbox" name="checkbox" />复选框5</label>

    <!-- 引入jQuery官方类库 -->
    <script type="text/javascript" src="js/jquery-1.8.3.min.js"></script>
    <!-- start 全选/全不选 -->
    <script type="text/javascript">
    $('input[name="checkall"]').on("click",function(){
    if($(this).is(':checked')){
    $('input[name="checkbox"]').each(function(){
    $(this).prop("checked",true);
    });
    }else{
    $('input[name="checkbox"]').each(function(){
    $(this).prop("checked",false);
    });
    }
    });
    </script>
    <!-- end 全选/全不选 -->
    </body>
    </html>

  • 相关阅读:
    嘀嘀咕 (1)
    碎碎念(4)
    渲染层错误] TypeError: Cannot read property 'replace' of undefined at rewrit
    怎么跳出foreach
    vs code的Go Live不出现
    ES6
    h5分享到微信,分享到朋友圈
    网页之间传值与获取值
    原生js添加节点的高级简便写法
    原型链
  • 原文地址:https://www.cnblogs.com/Fancy1486450630/p/10173885.html
Copyright © 2020-2023  润新知