简体   繁体   English

更改组合框时如何取消选中 jquery 表的复选框?

[英]How to uncheck the checkbox of a jquery table when changing a combobox?

I have the following question, when I change the value of the combobox, the checkboxes are still marked, with prop the values are unmarked, but this time it does not work, the idea is to reset the marked checkboxes when the value of the checkbox is changed.我有以下问题,当我更改组合框的值时,复选框仍然标记,prop 值未标记,但这一次不起作用,想法是当复选框的值更改时重置标记的复选框被改变。 Regards.问候。

                var cambio = $("#cmbKit").on('change', function () {
                    var checkPoint = !$(this).data('checked');
                    $('#tblCajas input[type="checkbox"]').each(function () {
                        if (checkPoint == true) {
                            $(':checkbox').prop('checked', false);
                            $("input[type='checkbox']").prop('checked', false);
                        } 
                    });
                });

                if (cambio) {
                    selectedBox = 0;

                    $('#divCalculos').hide();
                    $('#btnPlanificar').hide();
                }

As you want to reset every checkbox on change event of combobox, you can use below code -由于您想在组合框的更改事件上重置每个复选框,您可以使用以下代码 -

$("#cmbKit").change(function() {
    $("input[type='checkbox']").prop('checked', false);
});

You shouldn't use any if condition as you are going to reset it after every change event.您不应该使用任何 if 条件,因为您将在每次更改事件后重置它。
Please note that given code will reset all checkboxes on page, add table selector as well in case you have multiple table with different content.请注意,给定的代码将重置页面上的所有复选框,并添加表格选择器,以防您有多个内容不同的表格。
Hope this helps.希望这可以帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM