- jQuery checkbox 전체 선택
- jQuery checkbox 모두 체크
- jQuery checkbox check_all
- jQuery checkbox 체크 수 확인
1 예제 소스
html
Copy
<form name='my_form'>
<label><input type='checkbox' name='mycheck' value='apple' />사과</label>
<label><input type='checkbox' name='mycheck' value='pear' checked='checked' />배</label>
<label><input type='checkbox' name='mycheck' value='banana' />바나나</label>
<label><input type='checkbox' name='mycheck' value='melon' />멜론</label>
</form>
<button id='check_all'>모두 선택</button>
<button id='uncheck_all'>모두 해제</button>
<button id='count_check'>체크 수 확인</button>
<script src="//code.jquery.com/jquery.min.js"></script>
<script>
$("#check_all").click(function() {
$("input[name=mycheck]:checkbox").prop("checked", "checked");
});
$("#uncheck_all").click(function() {
$("input[name=mycheck]:checkbox").removeProp("checked");
});
$("#count_check").click(function() {
alert($("input[name=mycheck]:checkbox:checked").length);
});
</script>
2 같이 보기
편집자 Jmnote 210.105.39.178 112.216.110.226 106.242.182.122 Jmnote bot
로그인하시면 댓글을 쓸 수 있습니다.