gpt4 book ai didi

javascript - 单击下拉菜单时将复选框设置为未选中

转载 作者:行者123 更新时间:2023-11-30 11:33:06 25 4
gpt4 key购买 nike

如果使用 jQuery 选择了我的下拉列表,我希望能够取消选中复选框。我觉得我可能几乎就在那里,但无法弄清楚为什么它不起作用。例如,我单击 MR 但随后我更改为医生 - MR 保持选中状态。

<script>
$('.multiple-choice').click(function(){
$('input').prop('checked', false);
});
</script>

<fieldset class="title-box">

<span><input type="radio" name="title" value="Mr" onclick="titlehandler(this)" id="titlemr" th:field="*{title}" /> <label for="titlemr" id="mr-label">Mr</label></span>
<span><input type="radio" name="title" value="Mrs" onclick="titlehandler(this)" id="titlemrs" th:field="*{title}" /> <label for="titlemrs" id="mrs-label">Mrs</label></span>
<span><input type="radio" name="title" value="Miss" onclick="titlehandler(this)" id="titlemiss" th:field="*{title}" /> <label for="titlemiss" id="miss-label">Miss</label></span>
<span><input type="radio" name="title" value="Ms" onclick="titlehandler(this)" id="titlems" th:field="*{title}" /> <label for="titlems" id="ms-label">Ms</label></span>

<span><label for="dropdown">Other</label>
<select name="dropdown" id="dropdown" class="multiple-choice">


<option value="Dr" name="othertitle1" id="othertitle1">Dr</option>
<option value="Rev">Rev</option>
<option value="Sir">Sir</option>
<option value="Sist">Sist</option></select>
</fieldset>

<script>
$('.multiple-choice').click(function(){
$('input').prop('checked', false);
});
</script>
    <fieldset  class="title-box">

<span><input type="radio" name="title" value="Mr" onclick="titlehandler(this)" id="titlemr" th:field="*{title}" /> <label for="titlemr" id="mr-label">Mr</label></span>
<span><input type="radio" name="title" value="Mrs" onclick="titlehandler(this)" id="titlemrs" th:field="*{title}" /> <label for="titlemrs" id="mrs-label">Mrs</label></span>
<span><input type="radio" name="title" value="Miss" onclick="titlehandler(this)" id="titlemiss" th:field="*{title}" /> <label for="titlemiss" id="miss-label">Miss</label></span>
<span><input type="radio" name="title" value="Ms" onclick="titlehandler(this)" id="titlems" th:field="*{title}" /> <label for="titlems" id="ms-label">Ms</label></span>

<span><label for="dropdown">Other</label>
<select name="dropdown" id="dropdown" class="multiple-choice">


<option value="Dr" name="othertitle1" id="othertitle1">Dr</option>
<option value="Rev">Rev</option>
<option value="Sir">Sir</option>
<option value="Sist">Sist</option></select>
</fieldset>

最佳答案

试试这段代码:

<script>
$('.multiple-choice').click(function(){
$("input[type='radio'").each(function () {
$(this).prop('checked', false);
});
});
</script>

关于javascript - 单击下拉菜单时将复选框设置为未选中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45545195/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com