[英]How can I reset many radio button groups by selecting a specific radio button group
<input type="radio" value="three egg breakfast" name="type"> <img src="threeeggbreakfasttext.jpg" class="roundcorn"> <input type="radio" value="white toast" name="threeeggtoast"> <img src="whitetext.jpg" width="44" height="26" class="roundcorn"> <label><input type="radio" value="whole wheat toast" name="threeeggtoast"> <img src="wholewheattext.jpg" width="108" height="26" class="roundcorn"></label> <label><input type="radio" value="hash brown" name="threeeggside"> <img src="hashbrowntext.jpg" class="roundcorn"></label> <label><input type="radio" value="grits" name="threeeggside"> <img src="gritstext.jpg" width="44" height="26" class="roundcorn"></label> <input type="radio" value="ultimate omelette" name="type"> <img src="ultimateomelettetext.jpg" class="roundcorn"> <label> <input type="radio" value="bacon" name="omelettemeat"> <img src="bacontext.jpg" class="roundcorn"></label> <label> <input type="radio" value="ham" name="omelettemeat"> <img src="hamtext.jpg" class="roundcorn"></label> <label><input type="radio" value="white toast" name="omelettetoast"> <img src="/whitetext.jpg" class="roundcorn"></label> <label><input type="radio" value="whole wheat toast" name="omelettetoast"> <img src="wholewheattext.jpg" class="roundcorn"></label> </label><input type="radio" value="pancakes" name="type"> <img src="pancakestext.jpg" class="roundcorn"></label> <label><input type="radio" value="scrambled eggs" name="pancakeegg"> <img src="scrambledtext.jpg" class="roundcorn"></label> <label><input type="radio" value="eggs over easy" name="pancakeegg" > <img src="overeasytext.jpg" class="roundcorn"></label> <label><input type="radio" value="sausage patties" name="pancakemeat" > <img src="sausagepattiestext.jpg" class="roundcorn"></label> <label><input type="radio" value="beef smoked sausage" name="pancakemeat"> <img src="beefsmokedsausagetext.jpg" class="roundcorn"></label>
const typeInputs = document.querySelectorAll(`input[name=type][type=radio]`) // consider other name
const radioInputs = document.querySelectorAll(`input[type=radio]`) // consider other name
typeInputs.forEach(el => el.addEventListener("click", ({ target }) => {
radioInputs.forEach(input => {
if (input !== target)
input.checked = false;
})
}));
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.