Post

(jQuery) checkbox의 check all 기능 구현하기

1
2
3
4
5
6
7
<script>
/\* check-all 기능 \*/
$(".check-all").click(function () {
$(this.closest(".form-group")).find("input[type='checkbox']").not(this).prop('checked', this.checked);
});
</script>

페이지에 체크박스 폼이 하나만 있는 경우에는 그냥 모든 체크박스 선택해서 처리해도 되지만 form wizard같은거 쓰는 경우나, 체크박스 영역이 여러개 있는 경우 그 영역에 해당하는 체크박스들만 체크처리 해야 하므로 이런 식으로 처리하게 된다.

This post is licensed under CC BY 4.0 by the author.