I am trying to make the user check 3 checkboxes from the loop in the php. I don't get any errors but it doesn't limit the number of selection. Jquery
$(document).ready(function() {
    $('.single-checkbox').on('change', function() {
        var noChecked = 0;
        $.each($('.single-checkbox'), function() {
            if ($(this).is(':checked')) {
                noChecked++;
            }
        });
        if (noChecked >= 3) {
            $.each($('.single-checkbox'), function() {
                if ($(this).not(':checked').length == 1) {
                    $(this).attr('disabled', 'disabled');
                }
            });
        } else {
            $('.single-checkbox').removeAttr('disabled');
        };
    });
});
php:
$query="SELECT course.name FROM course";
$results=mysqli_query($dbhandle,$query) or die(mysqli_error($dbhandle));
while ($rows=mysqli_fetch_assoc($results)) {
print("<td><input class='single-checkbox' type='checkbox' id='ch' /></d> <td>".$rows['name']."</td>");
everything is working but the limitation is not working. Thank you in advance.
 
     
    