วันดี คืนดี ก็นั่งทำตัว Checkbox Select All สำหรับเลือกจัดการข้อมูลต่างๆ ในระบบได้หลายๆ ตัว ซึ่งก็ได้ออกมาแบบนี้ครับ
ลองเอาไปประยุกต์ใช้ดูนะครับ ^ ^
// Add multiple select
$('#selectAll').click(function(){
    var checkAll = $(this).prop('checked');
    
    $('.ChkBox').each(function(){
        $(this).prop({'checked':checkAll});
    });
});
// if all checkbox are selected, check the selectall checkbox
$('.ChkBox').click(function(){
    
    var chkNumRow = $('.ChkBox:checked').length;
    var chkMaxRow = $('.ChkBox').length;
    
    if(chkNumRow == chkMaxRow){
        $('#selectAll').prop({'checked':'checked'});
    }else{
        $('#selectAll').removeAttr('checked');
    }
});
Check All1234567
ลองเอาไปประยุกต์ใช้ดูนะครับ ^ ^
ความคิดเห็น
แสดงความคิดเห็น