工夫/JAVASCRIPT+JQUERY
[jQuery] 배열을 관리 each()
※ 가장 많이 쓰이는 용례 매개 변수로 받은 것을 사용해 for in 반복문과 같이 배열이나 객체의 요소의 값을 가져오는 것 (자체로 반복문의 기능을 수행한다) 사용법 // jQuery 유틸리티 메서드 $.each(object, function(index, item){ }); // jQuery 일반 메서드 $(selector).each(function(index, item){ }) ※ 주로 $(selector).each(function(index, element)) 형태가 쓰인다. 예제코드 1 2 3 $('div').find('span').each(function(index, item) { console.log($(this).text()); }); //결과 1 2 3
2021. 5. 19.