首页 > Web开发 > 详细

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

时间:2015-09-01 16:41:12      阅读:196      评论:0      收藏:0      [点我收藏+]
$(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);

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

原文:http://www.cnblogs.com/angellating/p/4775935.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!