목차

jQuery - each() Method

  • description : jQuery - each() Method
  • author : 오션
  • email : shlim@repia.com
  • lastupdate : 2022-11-23 Wed


Definition and Usage (w3schools)

each() 메소드는 각각의 요소에 대해 실행할 함수를 지정합니다.
Tip: return false를 사용하여 루프를 조기에 중지할 수 있습니다.

Syntax

$(selector).each(function(index, element))

.each(function)

jQuery객체에서 반복하며, 일치하는 각각의 요소에 대해 함수를 실행합니다.

function
Type: Function (Integer index, Element element)

The .each() method is designed to make DOM looping constructs concise and less error-prone.
When called it iterates over the DOM elements that are part of the jQuery object.
Each time the callback runs, it is passed the current loop iteration, beginning from 0.
More importantly, the callback is fired in the context of the current DOM element,
so the keyword this refers to the element.

.each() 메서드는 DOM 루핑 구성을 간결하고 오류가 덜 발생하도록 설계되었습니다.
호출되면 jQuery 개체의 일부인 DOM 요소를 반복합니다.
콜백이 실행될 때마다 0부터 시작하여 현재 루프 반복이 전달됩니다.
더 중요한 것은 콜백이 현재 DOM 요소의 컨텍스트에서 실행되므로,
키워드 this가 요소를 참조한다는 것입니다.

Source of the article