JQuery - Checkbox on-change event doesn't fire if checked using JQuery

后端 未结 5 888
忘掉有多难
忘掉有多难 2021-01-01 09:56

I have this Check All function which check all check boxes. I use JQuery to do that.

But I also have this on change function that toggle a

5条回答
  •  醉梦人生
    2021-01-01 10:55

    After click check all you should call change() event like this

    $(document).ready(function(){
        $("input[type='checkbox']").on('change', function(){
            $(this).closest('div').toggleClass('highlight');
        });
    
        $("#check_all").on('click', function(){
            $("input[type='checkbox']").prop('checked', true).change();
        });
    });
    

提交回复
热议问题