【发布时间】:2017-10-25 23:11:30
【问题描述】:
我有一个男性和女性的单选按钮。
我需要以下问题的帮助。
- 我必须显示男性单选按钮应该始终处于活动状态。
- 如何增加尺寸?我试图提供一些填充,但在后台解决了问题。
- 如何设置一些动画?
你会在这方面帮助我吗?
$('label.option').click(function() {
$('input[type=radio]').attr('checked',null);
$('label.option').removeClass("checked");
$(this).prev().attr('checked',"checked");
$(this).addClass("checked");
})
.border {
border:1px solid #000;
width: 150px;
border-radius: 30px;
text-align: center;
display: flex;
}
.width-half {
width: 75px;
}
input[type=radio] {
display: none;
}
.checked {
background-color: #00a2ff;
border-radius: 30px;
display: block;
color: #fff;
}
<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
<div class="border">
<div class="width-half">
<input type="radio" name="gender" value="male">
<label class="option">Male</label>
</div>
<div class="width-half">
<input type="radio" name="gender" value="female">
<label class="option">Female</label>
</div>
</div>
【问题讨论】:
标签: jquery html css radio-button css-animations