.first()
설명 : 일치하는 요소 집합을 집합의 첫 번째 집합으로 줄입니다.
DOM 요소 집합을 나타내는 jQuery 객체가 주어지면이 .first()메서드는 해당 집합의 첫 번째 요소에서 새 jQuery 객체를 생성합니다.
간단한 목록이있는 페이지를 고려해보십시오.
<ul>
<li>list item 1</li>
<li>list item 2</li>
<li>list item 3</li>
<li>list item 4</li>
<li>list item 5</li>
</ul>
이 메소드를 목록 항목 집합에 적용 할 수 있습니다.
$( "li" ).first().css( "background-color", "red" );
이 호출의 결과는 첫 번째 항목에 대한 빨간색 배경입니다.
예:
단락의 첫 번째 범위를 강조 표시하십시오.
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>first demo</title>
<style>
.highlight{
background-color: yellow
}
</style>
<script src="https://code.jquery.com/jquery-1.10.2.js"></script>
</head>
<body>
<p>
<span>Look:</span>
<span>This is some text in a paragraph.</span>
<span>This is a note about it.</span>
</p>
<script>
$( "p span" ).first().addClass( "highlight" );
</script>
</body>
</html>
게시글 목록
| 번호 | 제목 |
|---|---|
| 15854 |
jQuery
deferred.catch( failFilter )
|
| 15853 | |
| 15852 |
jQuery
.dblclick (handler)
|
| 15851 |
jQuery
제이쿼리 .data()
|
| 15849 |
jQuery
.css (propertyName)
|
| 15848 |
jQuery
.contextmenu( handler )
|
| 15847 |
jQuery
.contents()
|
| 15843 | |
| 15842 | |
| 15841 |
jQuery
.closest (selector)
|
| 15840 | |
| 15839 |
jQuery
제이쿼리 .click( handler )
|
| 15838 | |
| 15837 |
jQuery
제이쿼리 jQuery( ".class" )
|
| 15836 |
jQuery
제이쿼리 .children ([selector])
|
| 15835 |
jQuery
제이쿼리 jQuery ( ": checkbox")
|
| 15834 |
jQuery
제이쿼리 .change( handler )
|
| 15833 | |
| 15832 |
jQuery
제이쿼리 callbacks.locked ()
|
| 15831 |
jQuery
제이쿼리 callbacks.lock()
|
| 15830 | |
| 15829 | |
| 15828 |
jQuery
제이쿼리 callbacks.fired()
|
| 15826 | |
| 15825 | |
| 15824 |
jQuery
제이쿼리 callbacks.empty()
|
| 15823 |
PHP
rsa 암호화 클래스
|
| 15822 |
jQuery
제이쿼리 callbacks.disable ()
|
| 15821 | |
| 15820 |
jQuery
제이쿼리 .blur( handler )
|
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기