jQuery :nth-last-of-type() 선택기
예시
마지막 자식부터 계산하여 부모의 세 번째 <p> 요소인 각 <p> 요소를 선택합니다.
$("p:nth-last-of-type(3)")
정의 및 사용
:nth-last-of-type( n ) 선택기는 특정 유형의 부모 의 n 번째 자식인 모든 요소를 마지막 자식부터 계산하여 선택합니다.
팁: :nth-last-child() 선택기를 사용 하여 유형 에 관계없이 마지막 자식부터 계산하여 부모 의 n 번째 자식인 모든 요소를 선택합니다 .
통사론
:nth-last-of-type(n|even|odd|formula)
Parameter | Description |
---|---|
n | The index of each child to match. Must be a number. The first element has the index number 1. |
even | Selects each even child element |
odd | Selects each odd child element |
formula | Specifies which child element(s) to be selected with a formula (an + b). Example: p:nth-last-child(3n+2) selects each 3rd paragraph, starting at the last 2nd paragraph |
직접 해보십시오 - 예
첫 번째 <p> 요소인 각 <p> 요소를 선택하는 방법, 마지막 아이부터 계산합니다.
을 사용 하여
마지막 자식부터 계산하여 다른 <p> 요소를 선택하는 방법.
사용 짝수 및 홀수를 사용하여 마지막 자식부터 계산하여 다른 <p> 요소를 선택하는 방법.
의 차이점 p:nth-child(2), p의 차이점 :nth-last-child(2), p:nth-of-type(2) 및 p:nth-of-last-type(2).