1. 개수 구하기
$("input[name=chk1]:checkbox:checked").length
☆☆☆ php에서 배열사용시 ☆☆☆
$("input[name='chk1[]']:checked").length
2. 체크여부 확인
$("#check_all").is(':checked')
3. chk1 개수만큼 돌면서 실행한다
$("input[name=chk1]").each(
function (){
// 명령어
}
)
4. each 문돌면서 그값이 참이면 실행하는 문장
var chk2 = $("input[name='chk2[]']");
var i = 0;
$("input[name='chk1[]']").each(
function(){
if(this.checked){
chk2[i].value = "Y";
}else{
chk2[i].value = "N";
}
i++;
}
);
[출처] [jquery] checkbox 다루기 (JETT) |작성자 지훈이
'프로그램&DB > JQUERY' 카테고리의 다른 글
[jQuery] jQuery form 전송 (0) | 2011.08.29 |
---|---|
[jQuery] radio , select 에서 value 값 가져오기 (0) | 2011.08.29 |
[jQuery강좌] 20. jQuery Performance by 승연아빠님 (0) | 2011.08.09 |
[jQuery강좌] 19. jQuery Event - 이벤트에 생명을~ by 승연아빠님 (0) | 2011.08.09 |
[jQuery강좌] 18. jQuery Event - bind() 메서드 by 승연아빠님 (0) | 2011.08.09 |