mercredi 4 novembre 2020

Changing a Switchery checkbox state from javascript value

consider in javascript i have b = 1 i want swith state should be on if b == 1 so i have this code

if (b == 1){
            $('#cstvststatus').attr('checked', true);
        }
let elems = Array.prototype.slice.call(document.querySelectorAll('.js-switch'));
elems.forEach(function(html) {
    let switchery = new Switchery(html,  { size: 'small' });
});

check box

<input type="checkbox" id="cstvststatus" class="js-switch" >



Aucun commentaire:

Enregistrer un commentaire