您的位置:首页 > Web前端 > JQuery

[基于动态加载元素的全选与反选] Jquery 全选反选 (jquery版本有差异)

2016-05-25 15:00 501 查看
  $("#checkAll").on("click",function() {

            // res=$(this).is(":checked");

            if($(this).is(":checked")){

                $("input[name='list[]']").prop("checked","true");  /***低版本prop需要更换成attr方法***/

            }else{

                $("input[name='list[]']").removeProp("checked","");

            }
        });

        $(document).on("click","input[name='list[]']",function() {

            if($("input[name='list[]']").length == $("input[name='list[]']:checked").length){

                $("#checkAll").prop("checked","checked");

            }else{

                $("#checkAll").prop("checked","");

            }

        });
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  jquery