刷新的时候jquery获取checkbox是否为选中和设置选中

$(document).ready(function(){
    $('.uninstall_list_checkbox').click(function(){
        if($(this).parent('.uninstall_list').children('input').attr("checked")==true){ //判断是否选中
            $(this).parent('.uninstall_list').children('input').attr('checked',false); //设置未选中
        }
        else
        {
            $(this).parent('.uninstall_list').children('input').attr('checked',true);
        }
        /*if (!$(this).hasClass("checked")) { //判断是否有class为checked
            $(this).addClass("checked");   //添加class
            $(this).parent('.uninstall_list').children('input').attr('checked',true);  //设置复选框选中
        }
        else {
            $(this).removeClass("checked");
            $(this).parent('.uninstall_list').children('input').attr('checked',false);
        }*/
    });
});

判断checkbox是否为选中还有这种方法:

if($(this).parent('.uninstall_list').children('input').is(":checked"));

设置就是:$(this).parent('.uninstall_list').children('input').attr('checked',false);

posted @ 2015-09-01 15:57  努力的喵喵  阅读(348)  评论(0编辑  收藏  举报