How to Make Select All Check Box with PHP : i want when i click select all then all checkbox will selected and when i click again all checkbox will deselect.

but when i click it nothing happen.

my code

    <form id="sort_select_delete_form" method="get">
    
    <div class="btn-group">
    <a href="#check-all" class="btn btn-primary" id="check-all">Select All</a>
    <input type="submit" class="btn btn-danger" value="Delete Selected">
    </div>
    
    <input class="form-check-input" type="checkbox" value="1000000001" id="deleteid[]" name="deleteid[]">select1
    <input class="form-check-input" type="checkbox" value="1000000002" id="deleteid[]" name="deleteid[]">select2
    <input class="form-check-input" type="checkbox" value="1000000003" id="deleteid[]" name="deleteid[]">select3
    <input class="form-check-input" type="checkbox" value="1000000004" id="deleteid[]" name="deleteid[]">select4
    <input class="form-check-input" type="checkbox" value="1000000005" id="deleteid[]" name="deleteid[]">select5
    
    </form>

js

     $(document).ready(function(){
       $("#check-all").click(function(){
            var check = $(this).attr('checked');
            if(check=="checked")
            {
             $("#deleteid").attr('checked','checked');
            }
            else
             $("#deleteid").removeAttr('checked');
       });
     });

[jsfiddle link][1]


  [1]: https://jsfiddle.net/qa2fkpyv/2/