一佳一

记录像1+1一样简洁的代码

导航

CheckBoxList 全选(jquery版本)

Posted on 2014-04-07 14:11  一佳一  阅读(1094)  评论(0编辑  收藏  举报
 function selectedAll(allselect, obj) {
            $("#"+obj.id+" input:checkbox").each(function () {
                if (allselect.checked)
                    $(this).attr("checked", true);
                else {
                    $(this).attr("checked", false);
                }
            });
        }

调用

<input id="allCheck" onclick="selectedAll(this, document.getElementById('cbl_cg'))" type="checkbox" name="allCheck" />全选/反选