javascript&jquery
체크박스 일괄선택, 하위 객체 동시 선택 by jquery
에스크리토
2021. 2. 10. 13:27
반응형
$('.chkAll').click( function() {
$('.chkbx').prop( 'checked', this.checked );
});
$(".chkbx").bind("click", function(){
var pid=$(this).attr("id");
var ischeck=this.checked;
$(".chkbx").each(function(){
var tid=$(this).attr("id");
if(tid.indexOf(pid) != -1){
$("#"+tid).prop('checked', ischeck );
}
});
});
위에건 전체 선택...
아래건 선택한 체크박스의 하위 체크박스까지 모두 체크함.
대신 아이디에 부모 아이디가 포함돼 있어야함.
반응형