修改radio的选中颜色为红色

修改radio选中颜色为蓝色

在这里插入图片描述

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <title>修改radio的选中颜色为红色</title>
    <meta name="description" content="">
    <meta name="keywords" content="">
    <link href="" rel="stylesheet">
    <script crossorigin="anonymous" integrity="sha384-6ePHh72Rl3hKio4HiJ841psfsRJveeS+aLoaEf3BWfS+gTF0XdAqku2ka8VddikM" src="https://lib.baomitu.com/jquery/1.11.3/jquery.min.js"></script>
    <style type="text/css">
        .choose {
            position: relative;
        }

        .choose .radio {
            position: relative;
            display: inline-block;
            font-weight: 400;
            color: #0c4757;
            padding-left: 25px;
            cursor: pointer;
        }

        .choose .radio input {
            position: absolute;
            left: -9999px;
        }

        .choose .radio i {
            display: block;
            position: absolute;
            top: 3px;
            left: 0;
            width: 15px;
            height: 15px;
            outline: 0;
            border: 1px solid #e4e4e4;
            background: #ffffff;
            border-radius: 50%;
            transition: border-color .3s;
            -webkit-transition: border-color .3s;
        }
         .choose .radio input[checked="checked"]+i {
            border-color: blue;
        }

        .choose .radio input+i:after {
            position: absolute;
            content: '';
            top: 3px;
            left: 3px;
            width: 9px;
            height: 9px;
            border-radius: 50%;
            background-color: blue;
            opacity: 0;
            transition: opacity .1s;
            -webkit-transition: opacity .1s;
        }

        .choose .radio input:checked+i:after {
            opacity: 1;
        }
    </style>
</head>

<body>
    <div class="choose">
        <label class="radio">选项1<input type="radio" name="radio" value="1" checked="checked"><i></i></label>
        <label class="radio">选项2<input type="radio" value="2" name="radio"><i></i></label>
    </div>
    <script type="text/javascript">
        $(function () {
            $(".radio").find('input').click(function () {
                $(this).parent('label').siblings('label').find('input').removeAttr('checked') && $(this).attr('checked', 'checked');
            })
        })
    </script>
</body>

</html>

  • 1
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 8
    评论
评论 8
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值