• 회원가입
  • 로그인
  • 구글아이디로 로그인

[Selector] JQ - :last-of-type 가상선택자 - 타입 고려 마지막 자식요소 선택. (= 라스트 어브 타입 선택자)

목차
  1. :last-of-type 예제 - 그 부모의 타입 고려 마지막 자식p요소.
  2. :last-of-type 정의
  3. :last-of-type 구문
  4. :last-of-type 예제 - div의 타입 고려 마지막 자식p요소.
  5. :last-of-type 예제 - cf. :last, :last-child

 

:last-of-type 예제 - 그 부모의 타입 고려 마지막 자식p요소.

 

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>

<script>

$(document).ready(function(){

  $("p:last-of-type").css("background-color", "yellow");

});

</script>


<p>홈짱닷컴 Homzzang.com</p>

<div style="border:1px solid;">

  <p>HTML</p>

  <p>구조</p>

</div><br>

<div style="border:1px solid;">

  <p>CSS</p>

  <p>디자인</p>

  <span>구조 보충</span>

</div>

<p>홈페이지 제작관리 강의</p>

 

결과보기

 

:last-of-type 정의

 

그 부모의 타입 고려 마지막 자식요소 선택.

 


 

1.

:nth-last-of-type(1) 선택자와 동일.

 

2.

:first-of-type 선택자 : 그 부모의 타입 고려 첫번째 자식요소.

 

 

:last-of-type 구문

 

$(":last-of-type")

 

 

:last-of-type 예제 - div의 타입 고려 마지막 자식p 요소.

 

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>

<script>

$(document).ready(function(){

  $("div p:last-of-type").css("background-color", "yellow");

});

</script>


<p>홈짱닷컴 Homzzang.com</p>

<div style="border:1px solid;">

  <p>HTML</p>

  <p>구조</p>

</div><br>

<div style="border:1px solid;">

  <p>CSS</p>

  <p>디자인</p>

  <span>구조 보충</span>

</div>

<p>홈페이지 제작관리 강의</p>

 

결과보기

 

:last-of-type 예제 - cf. :last, :last-child

 

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>

<script>

$(document).ready(function(){

  $("button").click(function(){

    var btn = $(this).text();

    $("p").css("background-color", "white"); 

    $("p" + btn).css("background-color", "yellow"); 

  });

});

</script>


<button>:last</button>

<button>:last-child</button>

<button>:last-of-type</button><br>


<p>홈짱닷컴 Homzzang.com</p>

<div style="border:1px solid;">

  <p>HTML</p>

  <p>구조</p>

</div><br>

<div style="border:1px solid;">

  <span>CSS</span>

  <p>다지인</p>

  <p>구조보충</p>

  <span>인라인스타일, 내부스타일, 외부스타일</span>

</div><br>

<div style="border:1px solid">

  <p>JS</p>

  <p>동적기능</p>

</div>

<p>홈페이지 제작관리 강의</p>

 

결과보기

 


분류 제목
Effect JQ - stop() 메서드 ★ - 멈추게 하기 (= 슬라이드/애니 중단 = 움직임 멈추기/멈춤 = stop…
Effect JQ - Callback (콜백함수) ★ - 추가 호출 실행 함수
Effect JQ - Chaining 기법 ★ - 여러 메서드 연쇄 실행. (= 메서드 이어서 실행시키기. = 체이닝)
HTML_CSS JQ - text(), html(), val() , attr() 메서드 - (내용얻기/값얻기/속성얻기) (내… 2
HTML_CSS JQ - append(), prepend(), after(), before() 메서드 - (요소추가 / 내용…
HTML_CSS JQ - remove() / empty() 메서드 - (요소제거 / 내용삭제 / 내용비우기) ※ 리무브, 엠…
HTML_CSS JQ - addClass() , removeClass() , toggleClass() , css() 메서드 …
HTML_CSS JQ - css() 메서드 ★★★ - CSS 설정/반환 (= CSS메서드 = 스타일메서드) ※ 스타일 주기
HTML_CSS JQ - width() , height() , innerWidth() , innerHeight() , out…
Traversing JQ - Traversing - 특정요소찾기 (= 특정요소선택 = 트래버싱)
Traversing JQ - parent() , parents() , parentsUntil() 메서드 - 부모요소찾기 (= 부…
Traversing JQ - children() 메서드 - 자식요소찾기 / find() 메서드 - 자손요소찾기
Traversing JQ - 형제찾기 메서드 - siblings() , next() , nextAll() , nextUntil(…
Traversing JQ - 검색필터링 메서드 - first() , last() , eq() , filter() , not() …
AJAX JQ - AJAX (아작스) 소개 - 정의 / 기본예제 / 메서드종류
AJAX JQ - load() 메서드 ★ - 파일 내용 가져오기 (= load메서드 = 아작스 로드메서드)
AJAX JQ - get()/post() 메서드 - 서버에 정보요청 (= get메서드 = 겟메서드 / post메서드 …
Misc JQ - noConflict() 메서드 ★★★ - javascript (JS) 기반의 다른 프레임워크와의 충…
Examples jQuery Examples - 제이쿼리 예제 복습
Examples JQ - Quiz - 제이쿼리 퀴즈테스트
2/15
목록
찾아주셔서 감사합니다. Since 2012