미채택 완료

체크박스 관련

2019-09-01 (일) 09:52:18 3,098

name="chk_all" 인 체크박스 체크할때 다른것들이 일괄체크가 되질 않네요. 어디가 잘못됐을까요????

Copy
<link href="iosCheckbox.css" rel="stylesheet" type="text/css">


<input type="checkbox" name="chk_all" class="ios" value="1"  id="chk_all"> check all <br>
<input type="checkbox" name="agree" class="ios"/>
<input type="checkbox" name="agree" class="ios" />


<script src="http://code.jquery.com/jquery-1.11.1.min.js"></script>
<script src="iosCheckbox.js"></script>
<script>
$(document).ready(function(){

    jQuery(function($){
        // 모두선택
        $("input[name=chk_all]").click(function() {
            if ($(this).prop('checked')) {
                $("input[name^=agree]").prop('checked', true);
            } else {
                $("input[name^=agree]").prop("checked", false);
            }
        });
    });

    $(".ios").iosCheckbox();

});
</script>
|

답변 1개 / 댓글 1개

참고만 해 보새요.

<script>
$(function($){
// 모두선택
$("input[name=chk_all]").on('click', function() {
if($(this).prop('checked')) {
$("input[name^=agree]").prop('checked', true);
}else{
$("input[name^=agree]").prop("checked", false);
}
});

$(".ios").iosCheckbox();
});
</script>

답변에 대한 댓글 1개

2019-09-02 (월) 18:51:33
답변 감사드립니다. ^^

답변을 작성하려면 로그인이 필요합니다.