jQuery eq() 메서드

❮ jQuery 탐색 방법

예시

두 번째 <p> 요소(색인 번호 1)를 선택합니다.

$("p").eq(1).css("background-color", "yellow");

정의 및 사용

eq() 메서드는 선택한 요소의 특정 인덱스 번호를 가진 요소를 반환합니다.

인덱스 번호는 0에서 시작하므로 첫 번째 요소의 인덱스 번호는 0(1이 아님)이 됩니다.


통사론

$(selector).eq(index)

Parameter Description
index Required. Specifies the index of the element. Can either be a positive or negative number.

Note: Using a negative number will start the index count from the end of the selected elements, instead of the beginning.

직접 해보십시오 - 예


사용 음수를 사용하여 선택한 요소의 끝에서 두 번째 <p> 요소를 반환합니다.


❮ jQuery 탐색 방법