• 前端如何操作动态渲染的多个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()
            }
        })
  • 相关阅读:
    animation
    0201 ---背景 tableview
    0129 ---稳定定的 plist介绍
    0127 userdefault
    0127 数据库 我的专家
    0122 ---清理缓存
    0122 清楚缓存
    0122---screach
    0121 --view 可以当作线
    0119吧 iPhone 屏幕尺寸
  • 原文地址:https://www.cnblogs.com/wd163/p/14683814.html
Copyright © 2020-2023  润新知