티스토리 뷰

게시판 관리 및 이메일 등에서 자주보는 간단한 체크박스 전체 선택/해제 소스다.


*JQuery 사용

<table summary="체크박스 전체선택/해제 테이블. 전체선택, 내용 등을 제공">
<thead>
<th>
<label for="01">전체선택</label>
<input type="checkbox" id="01">
</th>
<th>내용</th>
</thead>
<tbody>
<tr>
<td><input type="checkbox" name="checkAll"></td>
<td>체크박스1</td>
</tr>
<tr>
<td><input type="checkbox" name="checkAll"></td>
<td>체크박스2</td>
</tr>
<tr>
<td><input type="checkbox" name="checkAll"></td>
<td>체크박스3</td>
</tr>
</tbody>
</table>


table {
text-align: center;
border-collapse: collapse;
}
table th, table td {
border: 1px solid blue;
}
view raw checkboxAll.css hosted with ❤ by GitHub


$(document).ready(function(){
$("#01").click(function(){
if($("#01").prop("checked")){
$("input[name=checkAll]").prop("checked",true);
}else{
$("input[name=checkAll]").prop("checked",false);
}
});
});
view raw checkboxAll.js hosted with ❤ by GitHub



'Language > JAVASCRIPT & JQUERY' 카테고리의 다른 글

데이터 깊은 복사 , 얕은 복사  (0) 2019.06.24
Ajax 비동기/동기  (0) 2017.08.30
엘리먼트 , div 영역 보이기 / 감추기  (0) 2016.06.23
댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2025/11   »
1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30
글 보관함