jq点击lable自定义单选框变换样式并且选中input

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_35069220/article/details/82624552

<style>

.ui-zidingyi {
    width: 20px;
    height: 20px;
    display: inline-block;
    background: url(../img/未选中-大.png) no-repeat;
    position: relative;
    top: 2px;
    left: 84px;
}

</style>

<div class="ui-dataLt">
                                    <label class="ui-zidingyi">
                                        <input name="vehicle" type="checkbox" />
                                    </label>             
  </div>

<scriput>

$(function() {
                $(".ui-zidingyi").toggle(function() {
                    $(this).css("background-image", "url(img/已选中-大.png)");
                    $(this).find("input").attr("checked","checked");
                    
                },function(){
                    $(this).css("background-image", "url(img/未选中-大.png)");
                    $(this).find("input").attr("checked",false);
                })
            });

</scriput>

猜你喜欢

转载自blog.csdn.net/qq_35069220/article/details/82624552
今日推荐