jQuery 슬라이스() 메서드

❮ jQuery 탐색 방법

예시

인덱스 번호가 2인 <p> 요소에서 <p> 요소 선택을 시작합니다.

$("p").slice(2)

정의 및 사용

slice() 메서드는 인덱스를 기반으로 요소의 하위 집합을 선택합니다.

부분 집합은 더 큰 집합의 일부인 집합입니다.

이 방법은 그룹의 요소 선택을 시작점과 끝점으로 제한하는 데 사용됩니다. 시작 매개변수는 하위 집합을 생성할 시작 색인(0에서 시작)이고 중지 매개변수는 선택적 끝점입니다.


통사론

$(selector).slice(start,stop)

Parameter Description
start Required. Specifies where to start the selection of elements. The index numbers start at 0.

Note: Using a negative number will select elements from the end of the selected elements, instead of the beginning.
stop Optional. Specifies where to end the selection of elements. If omitted, the selection continues until the end of the set. The index numbers start at 0.

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

직접 해보십시오 - 예


두 매개변수를 사용하여 시작점과 끝점에서 <p> 요소를 선택하는 방법.


사용 음수를 사용하여 시작 대신 끝에서 계산하는 <p> 요소 선택을 시작합니다.


사용 시작 및 중지를 음수로 사용하여 끝에서 계산하는 <p> 요소 선택을 시작합니다.


❮ jQuery 탐색 방법