码迷,mamicode.com
首页 > 其他好文 > 详细

复选框全选反选问题

时间:2017-06-21 11:51:35      阅读:122      评论:0      收藏:0      [点我收藏+]

标签:全选   mvc   logs   list   val   input   dispatch   rem   cti   

<script type="text/javascript">
    $(function(){
        $("#dispatch_btn").click(function(){
            var array = [];
            $(‘input[name=chk_list]‘).each(function(){
                if($(this).is(‘:checked‘))
                    array.push($(this).parent().next().val());
            });
            console.log(array);
        });
    });
    function allCheck(e){
        console.log("%o",e);
        if($("#chkall").is(‘:checked‘)){
            $(‘input[name=chk_list]‘).each(function() {
                console.log(this);
                $(this).prop("checked", true);
            });
        } else {
            $(‘input[name=chk_list]‘).each(function() {
                console.log(this);
                $(this).removeAttr("checked");
            });
        }
    }
</script>

springmvc控制器端可直接用String[]接受数组参数

注意点:

$(this).attr("checked",true)这种方式有可能只有一次生效,原因不明

复选框全选反选问题

标签:全选   mvc   logs   list   val   input   dispatch   rem   cti   

原文地址:http://www.cnblogs.com/shuo1208/p/7058113.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!