【发布时间】:2019-10-25 21:39:54
【问题描述】:
我的 jQuery 代码和单选按钮有问题, 如果我选择了一个按钮,另一个他保持选中状态,我不知道如何解决这个问题,如果有人可以帮助我解决我的问题,谢谢。我留下我的代码和屏幕截图,看看实际发生了什么。
$("#custom").click(function() {
$(".custom").css({
"display": "block"
})
})
$("#man").click(function() {
$(".custom").css({
"display": "none"
})
})
$("#ladies").click(function() {
$(".custom").css({
"display": "none"
})
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<input type="radio" id="ladies" name="ladies" value="ladies">
<label for="ladies">Ladies</label>
<input type="radio" id="man" name="man" value="man">
<label for="man">Man</label>
<input type="radio" id="custom" name="custom" value="custom">
<label for="custom">Custom</label>
<a href="#" class="icons"><i class="fas fa-question-circle fa-1x"></i></a>
<div class="custom">
<form action="#">
<select name='gender' id='gender'>
<option value='gender' disabled>Select the pronoun you are using</option>
<option value='she'>She: "Wihs her a happy brithday"</option>
<option value='he'>He: "Wish him a happy birthday!"</option>
<option value='he/she'>He / She: "Wish him / her a happy birthday!"</option>
</select>
<p class="genderTxt">The chosen pronoun is visible to everyone.</p>
<input type="text" class="optionalG" placeholder="Gender (optional)">
</form>
</div>
我没有任何错误信息要显示。
【问题讨论】:
-
一个组中的所有单选按钮必须具有相同的名称。
-
啊,是的。我是女士。
标签: javascript jquery html jquery-ui