首页 > Web开发 > 详细

jquery实现全选和取消全选

时间:2018-08-07 15:50:59      阅读:218      评论:0      收藏:0      [点我收藏+]
<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <title></title>
        <script src="http://code.jquery.com/jquery-2.1.1.min.js"></script>
    </head>
    <body>
        <input type="checkbox" id="checkall" />全选<br />  
        <input type="checkbox" name="check" /><br />  
        <input type="checkbox" name="check"/><br />  
        <input type="checkbox" name="check"/><br />  
        <input type="checkbox" name="check"/><br />
        <script>
            $("#checkall").on(click,function() {  
                $("input[name=‘check‘]").prop("checked", this.checked);  
            });  
            $("input[name=‘check‘]").on(click,function() {  
                  var $subs = $("input[name=‘check‘]");  
                  $("#checkall").prop("checked" , $subs.length == $subs.filter(":checked").length ? true :false);  
            }); 
        </script>
    </body>
</html>

 

jquery实现全选和取消全选

原文:https://www.cnblogs.com/zhangjianzhen/p/9437313.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!