首页 > Web开发 > 详细

js实现全选/全不选、反选

时间:2015-03-25 22:58:49      阅读:233      评论:0      收藏:0      [点我收藏+]
<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title></title>
    <script type="text/javascript" src="jquery-1.8.3.min.js"></script>
    <script type="text/javascript">
    $(function(){
        //全不选
        /*
        $(‘#checkAll‘).click(function() {
            var chk = $(this).prop(‘checked‘);
            $(‘input[name=choose]‘).prop(‘checked‘,chk);
        });
        */
        $(‘#checkAll‘).click(function() {
            $(‘input[name=choose]‘).prop(‘checked‘,this.checked);
        });
        //反选
        $(‘#checkRev‘).click(function(){
            $(‘input[name=choose]‘).each(function(){
                this.checked = !this.checked;
            });
        });
    });
    </script>
</head>
<body>
    <input type="checkbox" id="checkAll">全选/全不选<br>
    <input type="checkbox" id="checkRev">反选<br>
    <input type="checkbox" name="choose">1<br>
    <input type="checkbox" name="choose">2<br>
    <input type="checkbox" name="choose">3<br>
    <input type="checkbox" name="choose">4<br>
    <input type="checkbox" name="choose">5<br>
    <input type="checkbox" name="choose">6<br>
    <input type="checkbox" name="choose">7<br>
    <input type="checkbox" name="choose">8<br>
    <input type="checkbox" name="choose">9<br>
    <input type="checkbox" name="choose">10<br>
</body>
</html>

 

js实现全选/全不选、反选

原文:http://www.cnblogs.com/chenqionghe/p/4366912.html

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