삽질의 리포팅

[jquery]checkbox 전체 선택/해제

느린구름 2012. 3. 16. 14:43
//전체선택/해제
function jsCheckAll() {
    var status = $("#checkAll").attr('checked');
   
    if(status == 'checked'){
        $(".checkRow").attr('checked', 'checked');
    } else {
        $(".checkRow").attr('checked', false);
    }
}

<input type="checkbox" name="checkAll" />
<input type="checkbox" class="checkRow"/>
<input type="checkbox" class="checkRow"/>
<input type="checkbox" class="checkRow"/>