我有3个样式为单选的按钮:
<div class="col-md-12 form-group">
<label for="car-rental-pickup-location" class="mb-2">Pickup Location<small class="text-danger">*</small></label><br>
<div class="btn-group my-tab btn-group-toggle nav" data-toggle="buttons">
<a href="#tab-pickup" class=" btn btn-outline-secondary flex-fill pudo" data-toggle="tab">
<input type="radio" name="car-rental-pickup-location" id="car-rental-pickup-location-la" value="la" required onfocus="dateCheck();">Los Angeles
</a>
<a href="#tab-pickup" class="btn btn-outline-secondary flex-fill pudo" data-toggle="tab">
<input type="radio" name="car-rental-pickup-location" id="car-rental-pickup-location-sf" value="sf" onfocus="dateCheck();">San Francisco
</a>
<a href="#tab-pickup" class="btn btn-outline-secondary flex-fill pudo" data-toggle="tab">
<input type="radio" name="car-rental-pickup-location" id="car-rental-pickup-location-oc" value="oc" onfocus="dateCheck();">Orange County
</a>
</div>
</div>
屏幕截图:
当我重置表单或使用javascript检查其他单选按钮时,它们不会更新。如何更新这些单选按钮?
它正在运行:
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
<div class="col-md-12 form-group">
<label for="car-rental-pickup-location" class="mb-2">Pickup Location<small class="text-danger">*</small></label><br>
<div class="btn-group my-tab btn-group-toggle nav" data-toggle="buttons">
<a href="#tab-pickup" class=" btn btn-outline-secondary flex-fill pudo" data-toggle="tab">
<input type="radio" name="car-rental-pickup-location" id="car-rental-pickup-location-la" value="la" required onfocus="dateCheck();">Los Angeles
</a>
<a href="#tab-pickup" class="btn btn-outline-secondary flex-fill pudo" data-toggle="tab">
<input type="radio" name="car-rental-pickup-location" id="car-rental-pickup-location-sf" value="sf" onfocus="dateCheck();">San Francisco
</a>
<a href="#tab-pickup" class="btn btn-outline-secondary flex-fill pudo" data-toggle="tab">
<input type="radio" name="car-rental-pickup-location" id="car-rental-pickup-location-oc" value="oc" onfocus="dateCheck();">Orange County
</a>
</div>
</div>
答案 0 :(得分:0)
如果我正确理解了您的问题;您实际上需要确保未选中它们,提交表单或任何无法为您神奇地完成的表单。希望这会有所帮助,加油!
附录:在OP指定问题之后,罪魁祸首是锚标签let audioSession = AVAudioSession.sharedInstance()
var options = [AVAudioSession.CategoryOptions.allowBluetooth, AVAudioSession.CategoryOptions.allowAirPlay]
if mixWithOtherAudio {
options.append(AVAudioSession.CategoryOptions.mixWithOthers)
}
try audioSession.setCategory(
AVAudioSession.Category.playback,
mode: AVAudioSession.Mode.default,
policy: AVAudioSession.RouteSharingPolicy.longForm,
options: AVAudioSession.CategoryOptions(options)
)
保留其parentNode
css类,因此从视觉上看,它仍然看起来像是在组中选择了一个。补救措施如下;
active
resetGroup = (groupName) => {
const group = document.getElementsByName(groupName);
group.forEach(function(el) {
el.checked = false;
if (el.parentNode.classList.contains('active')) {
el.parentNode.classList.remove('active');
}
});
}