check/uncheck all checkboxes

后端 未结 4 1654
别跟我提以往
别跟我提以往 2021-01-21 02:45

I am trying to have a checkbox that checks/unchecks all the other checkboxes.

I am using this code:

$(\"#checkall\").toggle(   
    function () {
          


        
4条回答
  •  情歌与酒
    2021-01-21 03:44

    Try filtering out the checkbox in your selectors.

            $("#checkall").toggle(   
                function () {
                    $(".kselItems:not(#checkall)").attr('checked', 'checked');
                },
                function () {
                    $(".kselItems:not(#checkall)").removeAttr("checked"); 
            });
    

提交回复
热议问题