单选去除按钮,点击选中文字,修改文字颜色

页面单选radio点击选中文字改变其颜色

第一次写博客,请多多关照

二话不说上代码:
html:

<tr>
<td><p class="radio-font">性别</p></td>
<td>
    <input type="radio" class="radio" name="sex" value="" id="sex1"/>
    <label for="sex1" class="radio-font"></label>
    <input type="radio" class="radio" name="sex" value="" id="sex2"/>
    <label class="radio-font" for="sex2"></label>
</td>
</tr>

css:

.radio {
    display: none;
    width: 18px;
    height: 18px;
    border: 2px solid #FF0000;
    vertical-align:middle;
    margin-top:-2px;
    margin-bottom:1px;
}
.radio-font {
    line-height: 25px;
    padding: 25px;
    font-family: "PingFang SC", serif;
    font-size: 18px;
    margin-right: 25px;
    color:#444444;
    margin-top: 20px;
    vertical-align: -2px
}

js:

$(document).ready(function (){
    $(":radio").click(function (){
        $("input[type='carType']").each(function(){
            if(this.checked === true){
                $(this).next().css('color','#FF0000');
            }else{
                $(this).next().css('color','#444444');
            }
        });
    });
});

效果图:
效果图
效果图
在下也是个小白,写这个:
一是为了记录,以后想不起来可以回来找,
二是给各位跟我一样的小白一个参考.
上面这些是仿照下边链接进行修改的,希望对各位有用:
链接: https://blog.csdn.net/sinat_23668639/article/details/50132657

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值