checkbox 전체선택 / 전체해제 샘플코드

 

//	@ select all & uncheck all
jQuery("#check_all").click(function()
{
    jQuery("input[name=check_om01_pk]").prop("checked", this.checked);
});

// @ get checkbox status count
jQuery("input[name=check_om01_pk]").click(function()
{
    let loopCnt     =   0;
    let totalCnt    =   jQuery("input[name=check_om01_pk]").length;
    let Cnt_checked_true    =   0;
    let Cnt_checked_false   =   0;
    for(loopCnt=0; totalCnt>loopCnt; loopCnt++)
    {
        if( jQuery("input[name=check_om01_pk]")[loopCnt].checked == true )
        {
            Cnt_checked_true = Cnt_checked_true + 1;
        }// end if

        if( jQuery("input[name=check_om01_pk]")[loopCnt].checked == false )
        {
            Cnt_checked_false = Cnt_checked_false + 1;
        }// end if

    }// end for

    if( Cnt_checked_false > 0 )
    {
        jQuery("#check_all").prop("checked", false);
    }// end if
});