$('.class_checkbox').click(function() { var jumlah = $('input:checkbox:checked.class_checkbox').length; if(jumlah>5){ alert('crot'); $(this).removeAttr('checked'); } });