본문 바로가기

Programming/jQuery

[jQuery] checkbox 관련

jQuery checkbox 관련



check box 여부 확인

$("input:checkbox[id = 'ID']").is(":checked") == true : false
$("input:checkbox[name = 'NAME']").is(":checked") == true : false


checked/unchecked 처리

$("input:checkbox[id = 'ID']").attr("checked", true);

$("input:checkbox[name = 'NAME']").attr("checked", false);


check box 모두 체크/해제

$("#checkAll").click(function(){

    $("input[name=Name]:checkbox").each(function(){

        $(this).attr("checked", true);

    });

});

 

$("#checkAll").click(function(){

    $("input[name=Name]:checkbox").each(function(){

        $(this).attr("checked", false);

    });

});


attr로 변경이 안된다면

$(function(){
    $("#checkAll").click(function(){
        $(".check").prop("checked", $(this).is(":checked"));
    });
});


체크되어 있는 값

$("#btn_count").on("click", function(){

$("input[name=cbbox]:checked").each(function() {

var test = $(this).val();

console.log(test);

});

});





'Programming > jQuery' 카테고리의 다른 글

[jQuery] Ajax 전송  (0) 2014.08.14
[jQuery] HTTP Body로 Ajax JSON POST  (0) 2014.08.14
[jQuery] input box 기본문자처리  (0) 2014.08.14
[jQuery] select box 관련  (0) 2014.03.19
[jQuery] when() 함수  (0) 2014.03.19