dimanche 18 février 2018

check uncheck all after some checkboxes are clicked

   <input id='checkall' type='checkbox'> 

   <input class='checka' type='checkbox'>
    <input class='checka' type='checkbox'>
    <input class='checka' type='checkbox'>
    <input class='checka' type='checkbox'>

js

$('#checkall').change(function(){
    if ($(this).is(':checked')){
        $('.checka').attr('checked', true);
    }
    else{
        $('.checka').attr('checked', false);
    }
});

After loading the page this works fine.

But if some of the checka is checked/unchecked before checkall click - it works only on non-clicked checka.




Aucun commentaire:

Enregistrer un commentaire