jQuery ( ": first-of-type")
jQuery ( ": first-of-type")
설명 : 동일한 요소 이름의 형제 중 첫 번째 요소를 모두 선택합니다.
:first-of-type선택은 같은 부모와 문서 트리에 전에 오는 같은 요소 이름 모두 다른 요소가없는 요소를 일치합니다.
예:
일치하는 각 div에서 첫 번째 범위를 찾아 클래스를 추가하십시오.
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>first-of-type demo</title>
<style>
span.fot {
color: red;
font-size: 120%;
font-style: italic;
}
</style>
<script src="https://code.jquery.com/jquery-1.10.2.js"></script>
</head>
<body>
<div>
<span>Corey,</span>
<span>Yehuda,</span>
<span>Adam,</span>
<span>Todd</span>
</div>
<div>
<b>Nobody,</b>
<span>Jörn,</span>
<span>Scott,</span>
<span>Timo</span>
</div>
<script>
$( "span:first-of-type" ).addClass( "fot" );
</script>
</body>
</html>
게시판 목록
개발자팁
개발과 관련된 유용한 정보를 공유하세요.
질문은 QA에서 해주시기 바랍니다.
질문은 QA에서 해주시기 바랍니다.
| 번호 | 분류 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|---|
| 4796 | jQuery | 8년 전 | 1540 | ||
| 4795 | jQuery | 8년 전 | 1444 | ||
| 4794 | jQuery | 8년 전 | 1568 | ||
| 4793 | jQuery | 8년 전 | 1622 | ||
| 4792 | jQuery | 8년 전 | 1638 | ||
| 4791 | jQuery | 8년 전 | 1797 | ||
| 4790 | jQuery | 8년 전 | 1737 | ||
| 4789 | jQuery | 8년 전 | 1600 | ||
| 4788 | jQuery | 8년 전 | 1661 | ||
| 4787 | jQuery | 8년 전 | 1476 | ||
| 4786 | jQuery | 8년 전 | 1436 | ||
| 4785 | jQuery | 8년 전 | 1648 | ||
| 4784 | jQuery | 8년 전 | 1533 | ||
| 4783 | jQuery | 8년 전 | 1237 | ||
| 4782 | jQuery | 8년 전 | 1605 | ||
| 4781 | jQuery | 8년 전 | 1344 | ||
| 4780 | jQuery | 8년 전 | 1578 | ||
| 4779 | jQuery | 8년 전 | 1988 | ||
| 4778 | jQuery | 8년 전 | 1963 | ||
| 4777 | jQuery | 8년 전 | 1535 | ||
| 4776 | jQuery | 8년 전 | 1589 | ||
| 4775 | jQuery | 8년 전 | 1976 | ||
| 4774 | jQuery | 8년 전 | 1491 | ||
| 4773 | jQuery | 8년 전 | 1417 | ||
| 4772 | jQuery | 8년 전 | 2206 | ||
| 4771 | jQuery | 8년 전 | 3622 | ||
| 4770 | PHP | 8년 전 | 5586 | ||
| 4769 | 기타 | 8년 전 | 1967 | ||
| 4768 | 기타 | 8년 전 | 1785 | ||
| 4767 | 기타 | 8년 전 | 2074 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기