admin 评论(0) 2021-01-11 JS



input[type="radio"] + label::before {
    content: "\a0"; /*不换行空格*/
    display: inline-block;
    vertical-align: middle;
    width: 1em;
    height: 1em;
    margin-right: .4em;
    border-radius: 50%;
    text-indent: .15em;
    line-height: 1;
    background: url('../img/select_b.png');
    background-size: 100%;
    z-index: 18;
    position: relative;
}
input[type="radio"]:checked + label::before {
    background-clip: content-box;
    background: url('../img/select_h.png');
    background-size: 100%;
    position: relative;
}
input[type="radio"] {
    position: absolute;
    clip: rect(0, 0, 0, 0);
} 


<div class="select_a_div">
    <input type="radio" id="xuanxianga" name="zhongyin" />
    <label for="xuanxianga">label>
div>

<div class="select_b_div">
    <input type="radio" id="xuanxiangb" name="zhongyin" />
    <label for="xuanxiangb">label>
div>


$("#xuanxianga").prop("checked","checked");


**如果你的jQuery库的版本是1.6以下的,使用attr方法
如果你的jquery库的版本是1.6(含1.6)以上的,使用prop方法**
$(':radio[value='+data[2]+']').prop('checked',true);


评论
    你来打破0评论