개발노트/jQuery
foreach문이란? foreach 응용
워기
2016. 12. 6. 18:56
## FOREACH 문
.each()함수는 jQuery 객체의 수만큼 for 문 같이 반복을 해주는 함수입니다.
$('input', $('#TABLE명')).each(function () { // TABLE명이라는 id를 가진 table 안에 모든 input만큼 each를 실행
$(this).attr("disabled", "disabled"); //모든 input 속성을 disabled 시킨다.
if ( ($(this).attr("id") == "AAA")||($(this).attr("id") == "BBB") ) {
$(this).removeAttr("disabled");
}
});
.each()함수는 jQuery 객체의 수만큼 for 문 같이 반복을 해주는 함수입니다.
$('input', $('#TABLE명')).each(function () { // TABLE명이라는 id를 가진 table 안에 모든 input만큼 each를 실행
$(this).attr("disabled", "disabled"); //모든 input 속성을 disabled 시킨다.
if ( ($(this).attr("id") == "AAA")||($(this).attr("id") == "BBB") ) {
$(this).removeAttr("disabled");
}
});