• 自定义checkbox和radio的样式


    1.HTML

    <div class="checked">
       <input type="checkbox" >
    </div> <div class="radio">
      <div class="checked1">
        <input type="radio" name="sex" value="0"> 男
      </div> <div class="checked1 no"> <input type="radio" name="sex" value="1" checked> 女 </div> </div>

     2.CSS

     

    .checked{
       52px;
       height:52px;
       background:url("img/huiyuanye_weixuanzhong.png") no-repeat;
       background-size:100% 100%;
    }
    .radio{
       overflow: hidden;
    }
    .checked1{
       90px;
       height:52px;
       float:left;
       background:url("img/huiyuanye_weixuanzhong.png") no-repeat;
       background-size:52px 52px;
    }
    .no{
       background:url("img/huiyuanye_xuanzhong.png") no-repeat;
    }
    .checked input,.checked1 input{
       50px;
       height:50px;
       opacity: 0;
    }
    

     3.js

    $(".checked").on('click',function(){
        var flag = $(this).find("input").get(0).checked;
        if(flag){
           $(this).addClass("no");
        }else{
           $(this).removeClass("no");
        }
        console.log(flag);
    })
    console.log($(".checked").find("input").get(0).checked);
    console.log($('input:radio[name="sex"]:checked').val());
    $("input[type='radio']").on('click',function(){
         console.log($(this).val())
          $(this).parent().addClass("no").siblings().removeClass("no");
    })
    

      

     

  • 相关阅读:
    jesperreport+ireport简单理解
    tomcat服务器奇异事件
    Spring+SpringMvc+Mybatis整合注意事项
    Websocket简单例子
    uploadify前台上传文件,java后台处理的例子
    违反完整约束条件 (XXX)
    插入排序
    选择排序
    冒泡算法(思路二)
    2-3树
  • 原文地址:https://www.cnblogs.com/dyy-dida/p/10371404.html
Copyright © 2020-2023  润新知