last / last-child / last-of-type
:first / :first-child / :first-of-type / :last / :last-child / :last-of-type을 통하여
비교적 더 자신이 원하는 요소를 가져올 수 있다.
선택자 이후의 코드 설명은 간단한 코드이기에 생략하겠다.
6. first / last
1 | $('p:first').css('background-color','red'); | cs |
(E):first/last
document의 요소 중에 첫번째(마지막) E 유형을 찾는다.
7. first-child / last-child
1 | $('p:first-child').css('background-color','red'); | cs |
(E):first-child / last-child:
document의 요소에서 부모를 가지고 있는 자식 중에
첫번째(마지막) 자식이 E 유형 인 것을 찾는다.
8. :first-of-type / last-of-type
1 | $('p:first-of-type').css('background-color','red'); | cs |
(E):first-of-type / last-of-type:
E 유형의 첫번째(마지막) 형제를 선택하는 선택자이다.
'이전 글 > JQuery' 카테고리의 다른 글
6. jQuery 선택자 - :even / :odd / :only-child / :only-of-type (0) | 2018.01.23 |
---|---|
5. jQuery 선택자 - :nth-child / nth-of-type / :nth-last-child / nth-last-of-type (0) | 2018.01.23 |
3. jQuery 선택자 - * / #/ . / [] / element (0) | 2018.01.23 |
2. jQuery 선택자(selector)란? (0) | 2018.01.23 |
1. jQuery 란? (0) | 2018.01.23 |