Jsp
each() [JavaScript]
민돌이
2017. 1. 12. 14:11
반응형
each()
다른 언어들의 for, while 문과 동일한 기능을 함.
사용법.
1. DOM 반복
$(selector).each(function() {
내용.
});
1-2. element에 해당되는 값도 구할 수 있다.
$(selector).each(function(index, element) {
내용.
)};
2. Array, Object의 반복을 할 때에는.
$.each([1,2], function(index, value) {
alert( index + " : " + value );
});
2-2. Object 의 반복
$.each(obj, function(key, value) {
alert( key + " : " + value );
});
반응형