【发布时间】:2023-03-27 05:45:02
【问题描述】:
我有这个单选按钮。选中 no 时,必须禁用和取消选中下一个顶部单选按钮(这可行)。当用户点击 yes 时,接下来的两个单选按钮应该被启用并且可以点击。这就是问题所在 - 点击yes按钮仍然无法点击。我做错了什么。我的代码如下。感谢您的帮助!
$(document).ready(function() {
$(".blind-7").attr('disabled', true);
$(".blind-8").attr('disabled', true);
$(".nebel-3").css('opacity', '0.1');
$("form input:radio").change(function() {
if ($('#033b').is(':checked')) {
$(".blind-7, .blind-8").attr('disabled', true);
$(".blind-7").prop('checked', false);
$(".blind-8").prop('checked', false);
$(".nebel-3").css('opacity', '0.1');
}
else if ($('#033a').is(':checked')) {
$(".blind-7, .blind-8").attr('disabled', false);
$(".nebel-3").css('opacity', '1');
}
});
});
.nebel {
color: black;
background: #F9CA83;
}
.nebel-3 {
color: black;
background: #F9CA83;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<label class="nebel" for="033">click here</label>
<input id="033b" type="radio" name="question" value="0"checked> <label for="033b">no</label>
<input id="033a" type="radio" name="question" value="1"> <label for="033a">yes</label>
<label class="nebel-3" for="034">type</label>
<input id="034b" class="blind-8" type="radio" name="type" value="0" > <label for="034b">A</label>
<input id="034a" class="blind-7" type="radio" name="type" value="1"> <label for="034a">B</label><br />
<label class="nebel-3" for="035">time</label>
<input id="035b" class="blind-8" type="radio" name="time" value="0" > <label for="035b">acute</label>
<input id="035a" class="blind-7" type="radio" name="time" value="1"> <label for="035a">chronic</label>
【问题讨论】:
标签: javascript jquery html css radio-button