JQuery radio 全选与反选

项目需要,参照网上提供的方法测试出正确方案,记录下方便使用

            //全选
            $("#checkall").click(function () {
                if (this.checked) {
                    $("input[name='cball']").attr("checked", true);
                } else {
                    $("input[name='cball']").attr("checked",false);
                }
            });
            //反选
            $("#reverselect").click(function () {
                $("input[name='cball']").each(function () {
                    if ($(this).attr("checked")) {
                        $(this).attr("checked", false);
                    } else {
                        $(this).attr("checked", true);
                    }
                });
            });

 


版权声明:本文为zhangxiao0122原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。