Javascript 添加/删除带有限制的不同输入的复选标记

Javascript 添加/删除带有限制的不同输入的复选标记,javascript,jquery,input,onchange,Javascript,Jquery,Input,Onchange,我有三个选项,如果你点击一个选项,上面会显示一个复选标记,表示该选项已被选中。我最多只能买一套。现在,需要再次单击图像/当前复选标记输入以删除它,而不是简单地单击另一个选项并删除它 我试图设置一个代码片段来复制我实际拥有的内容,但由于某种原因,复选标记没有显示出来。不管怎样,我正在尝试将我在另一篇文章中看到的解决方案与以下内容合并:$('').not(this).prop('checked',false) 但我不知道如何将其添加到我的代码中以使其正常工作。我试过: $(this).parents

我有三个选项,如果你点击一个选项,上面会显示一个复选标记,表示该选项已被选中。我最多只能买一套。现在,需要再次单击图像/当前复选标记输入以删除它,而不是简单地单击另一个选项并删除它

我试图设置一个代码片段来复制我实际拥有的内容,但由于某种原因,复选标记没有显示出来。不管怎样,我正在尝试将我在另一篇文章中看到的解决方案与以下内容合并:
$('').not(this).prop('checked',false)

但我不知道如何将其添加到我的代码中以使其正常工作。我试过:

$(this).parents('.product wrap:first').find('.checkmark img').fadeboltogle(this.checked).not(this.prop)('checked',false)

$(this).parents('.product wrap:first').find('.checkmark img').not(this).prop('checked',false.).fadeBoolToggle(this.checked)

有人知道我如何在单击另一个复选标记输入选项时切换复选标记输入吗

这是与之关联的代码块

$('.calendar-check').on('change', function () {
        //    $('').not(this).prop('checked', false);
        if (!this.checked || $('.calendar-check:checked').length <= limitCal) {
            $(this).parents('.product-wrap:first').find('.checkmark-img').fadeBoolToggle(this.checked);

A.
B
C

如果您试图只选中一个复选框,则需要在每个输入字段中添加一个相同的名称(如果您想使用radio,则需要jQuery for checkbox):

<div>
   <input name="checkMark" type="checkbox" />
</div>
<div>
   <input name="checkMark" type="checkbox" />
</div>
<div>
   <input name="checkMark" type="checkbox" />
</div>


基本上你是说,无论你点击哪一个,其余的输入都会被检查为false。

这不起作用。仍然需要单击选中的复选框输入来删除选择。这一定与我如何添加复选标记图像有关。是的,对不起,我认为复选框的工作原理与收音机相同,但我不欣赏你的尝试!我只是不知道如何将它写入我的函数中。我知道这段代码
$('input.calendar check')。不是(this.attr('checked',false)
使它工作,但我需要它与
$(this.parents('.product wrap:first').find('.checkmark img').fadeboltogle(this.checked)一起工作因为这是使复选标记显示在选项图像上的原因。我只是不知道如何将两者结合起来。
$('.calendar-check').on('change', function () {
    //    $('').not(this).prop('checked', false);
    if (!this.checked || $('.calendar-check:checked').length <= limitCal) {
        $(this).parents('.product-wrap:first').find('.checkmark-img').fadeBoolToggle(this.checked);
    }
});
$('input.calendar-check').on('click', function(){
    $('input.calendar-check').not(this).attr('checked', false);
})