전체 선택은 어떻게 만들죠??
본문
예를들어
이렇게 체크박스가 4개라고 할때 전체선택을 누르면 체크가 되는 방식 그리고 전송시키는 방식은 어떻게 만드나요..? 예시를..
전체선택 <input type="checkbox" name="all">
<input type="checkbox" name="1">
<input type="checkbox" name="2">
<input type="checkbox" name="3">
<input type="checkbox" name="4">
답변 4
전체선택 <input type="checkbox" name="all" class="all">
<input type="checkbox" class="chk" name="1">
<input type="checkbox" class="chk" name="2">
<input type="checkbox" class="chk" name="3">
<input type="checkbox" class="chk" name="4">
<script src="//code.jquery.com/jquery.min.js"></script>
<script>
$(document).ready(function(){
$(".all").click(function(){
if($(".all").prop("checked")){
$(".chk").prop("checked",true);
}else{
$(".chk").prop("checked",false);
}
})
})
</script>
모두 답변 감사합니다.
다 좋은 방법이고 잘 적용 했습니다.
채택은 제가 가장 좋다고 생각되는 소스로 채택 했으니 이해 해주세요~
답변을 작성하시기 전에 로그인 해주세요.