samedi 15 février 2020

How to deselect multiple Switchery checkboxes using javascript

I have several checkbox Switchery components in which I control the IDs, as they are created dynamically. I need to go through all of them and deselect them using javascript. It's not working ... Does anyone know how to do it?

enter image description here

$("#div-enderecos").on("change", ".ckb-endereco-principal", function () {
    var enderecoTipo = $(this).closest('.row').find('.sel-endereco-tipo').val();      

    $("#div-enderecos .row").each(function (indice, elemento) {

        if ($(this).closest('.row').find('.sel-endereco-tipo').val() === enderecoTipo) {
            $("PessoaViewModel_PessoasEnderecosViewModel_" + indice + "__EnderecoPrincipal").attr('checked', false);
        }            
    });

});



Aucun commentaire:

Enregistrer un commentaire