前端如何操作动态渲染的多个checkbox列表单选

input[type=checkbox]:after{
    content:"";
    display:inline-block;
    16px;
    height:16px;
    border-radius:100%;
    background:#fff;
    border:1px solid gray;
    background:url(../images/未选中.png) no-repeat center center ;
    background-size:100% 100%;
}
input[type=checkbox]:checked:after{
    background:url(../images/选中.png) no-repeat center center ;
    background-size:100% 100%;
    border:none;
    16px;
    height:16px;
}

1.未来元素绑定点击时间用on,live在新版本的jq中被移除

$('.循环列表的父元素(静态元素)').on('click','input',function(){
    if($(this).is(":checked")){
        $('input').not(this).removeAttr('checked')
    }else{
        $(this).attr('checked','checked');
    }
})

2.在之后的逻辑里如何获取选中信息:

 $('.动态父元素 input').each(function(i){
        if($(this).is(":checked")){
           //通过相关dom结构找信息.html()/.val()
        }
    })
原文地址:https://www.cnblogs.com/wd163/p/14683814.html