Bootstrap Switch, global checkbox to (un)check all other

后端 未结 3 908
走了就别回头了
走了就别回头了 2021-01-12 00:18

I am using Bootstrap Switch for Twitter Bootstrap. Here I have problem to check or uncheck all checkbox based on global checkbox checked or unchecked

Here is the boo

3条回答
  •  清酒与你
    2021-01-12 00:45

    Try this:

     
    

    then in your script

        $('#rowSelectAll').on('change', function(){
        $('.myswitch').each(function(){
    
            if($(this).hasClass('switch-on')){
                $(this).bootstrapSwitch('setState' , false);
                $(this).removeClass('switch-on');
            }else{
    
           $(this).bootstrapSwitch('setState' , true);
            $(this).addClass('switch-on');
            }
        });
    });
    

提交回复
热议问题