반응형
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<script src="http://code.jquery.com/jquery-latest.min.js"></script>
<script>
$(document).ready(function() {
$("#total").click(function() {
if ($("#total").prop("checked")) {
$("input[type=checkbox]").prop("checked", true);
} else {
$("input[type=checkbox]").prop("checked", false);
}
});
});
</script>
<title>Document</title>
</head>
<body>
<table>
<tr>
<th class="boardChk"><input type="checkbox" id="total" />전체</th>
</tr>
<tr>
<td><input type="checkbox" id="test[]" />테스트1</td>
</tr>
<tr>
<td><input type="checkbox" id="test[]" />테스트2</td>
</tr>
<tr>
<td><input type="checkbox" id="test[]" />테스트3</td>
</tr>
<tr>
<td><input type="checkbox" id="test[]" />테스트4</td>
</tr>
</table>
</body>
</html>
반응형
'2020 > JQuery' 카테고리의 다른 글
JQuery 엘리먼트 순서 알아내기 (0) | 2020.03.05 |
---|---|
JQuery height, width (0) | 2020.03.05 |
Jquery focus, blur, focusin, focusout (0) | 2020.03.05 |
JQuery change (0) | 2020.03.04 |
JQuery window.resize (0) | 2020.03.04 |