[22/04/14] 자바스크립트 공부

Que Lin·2022년 4월 14일
0

1day 1commit

목록 보기
59/63

체크박스 다중선택 value값 가져오기

$("input[name=tblChk]:checked").each(function(){
        var test = $(this).val();
        console.log("체크된 값 : " + test);
});

체크박스 다중선택 value값 배열에 담기

var arTest = [];
$("input[name=tblChk]:checked").each(function(){
	arTest.push($(this).val());
});
console.log("체크된 값 total : " + arTest);
var times = $("#times").val();
var timeSplit = times.split(",");
for ( var i in timeSplit ) {
  $("input[type='checkbox'][value='"+timeSplit[i]+"']").prop('checked', true);
 }
profile
1일 1커밋 1일 1벨로그!

0개의 댓글