그때 그때/JQUERY
전체선택 checkbox
web_seul
2020. 9. 18. 11:16
$(function(){
//전체선택 체크박스 클릭
$("#allCheck").click(function(){
//만약 전체 선택 체크박스가 체크된상태일경우
if($("#allCheck").prop("checked")) {
//해당화면에 전체 checkbox들을 체크해준다
$("input[type=checkbox]").prop("checked",true);
// 전체선택 체크박스가 해제된 경우
} else {
//해당화면에 모든 checkbox들의 체크를해제시킨다.
$("input[type=checkbox]").prop("checked",false);
}
})
})
<table>
<tr>
<td> 전체선택 : <input type="checkbox" id="allCheck"/> </td>
</tr>
<tr>
<td> <input type="checkbox"/> </td>
</tr>
<tr>
<td> <input type="checkbox"/> </td>
</tr>
<tr>
<td> <input type="checkbox"/> </td>
</tr>
<tr>
<td> <input type="checkbox"/> </td>
</tr>
<tr>
<td> <input type="checkbox"/> </td>
</tr>
</table>
jquery 체크박스 전체 선택/해제 샘플소스
jQuery attr / prop 함수에 대해서 설명하던 도중 생각이나서 작성하게 되었습니다. 심플한 소스입니다. Insert title here 전체선택 : 도움이 되셨다면 손가락↓ 클릭! 궁금하신점은 댓글!!
roqkffhwk.tistory.com
반응형