jQuery ( "# id")
id : 검색 할 ID이며 요소의 id 속성을 통해 지정됩니다.
id 선택자의 경우 jQuery document.getElementById()는 매우 효율적인 JavaScript 함수를 사용합니다 . id 선택기에 다른 선택기가 연결 h2#pageTitle되면 jQuery는 요소를 일치로 식별하기 전에 추가 검사를 수행합니다.
id 선택자를 인수로 사용하여 jQuery()(또는 $())를 호출 하면 0 또는 하나의 DOM 요소 콜렉션을 포함하는 jQuery 객체가 반환됩니다.
각 id값은 문서 내에서 한 번만 사용해야합니다. 두 개 이상의 요소에 동일한 ID가 할당 된 경우 해당 ID를 사용하는 쿼리는 DOM에서 첫 번째로 일치하는 요소 만 선택합니다. 그러나이 동작에 의존하면 안됩니다. 동일한 ID를 사용하는 두 개 이상의 요소가있는 문서가 유효하지 않습니다.
id에 마침표 나 콜론과 같은 문자가 포함되어 있으면 해당 문자를 백 슬래시 로 이스케이프 처리해야 합니다.
예 :
ID가 "myDiv"인 요소를 선택하고 빨간색 테두리를 지정하십시오.
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>id demo</title>
<style>
div {
width: 90px;
height: 90px;
float: left;
padding: 5px;
margin: 5px;
background-color: #eee;
}
</style>
<script src="https://code.jquery.com/jquery-1.10.2.js"></script>
</head>
<body>
<div id="notMe"><p>id="notMe"</p></div>
<div id="myDiv">id="myDiv"</div>
<script>
$( "#myDiv" ).css( "border", "3px solid red" );
</script>
</body>
</html>
게시글 목록
| 번호 | 제목 |
|---|---|
| 15969 |
jQuery
.jquery
|
| 15968 |
JavaScript
공휴일을 제외한 시간적용 ON/OFF 스크립트예제 (휴일추가가능)
|
| 15967 |
jQuery
.is()
|
| 15966 |
jQuery
.insertBefore()
|
| 15965 |
jQuery
.insertAfter()
|
| 15964 |
jQuery
.innerWidth ()
|
| 15963 |
jQuery
.innerHeight ()
|
| 15962 |
jQuery
.index()
|
| 15961 |
jQuery
jQuery( ":image" )
|
| 15960 |
jQuery
jQuery ( "# id")
현재글
|
| 15959 |
jQuery
.html()
|
| 15958 | |
| 15957 |
jQuery
.hide ()
|
| 15956 |
jQuery
jQuery ( ": hidden")
|
| 15955 |
기타
그누보드5 기본쿼리
|
| 15954 |
jQuery
.height()
|
| 15953 |
jQuery
jQuery ( ": header")
|
| 15952 |
jQuery
.hasClass( className )
|
| 15949 |
PHP
네이버 클로버 tts
3
|
| 15947 |
node.js
네이트온 팀룸으로 메일 수신 확인
1
|
| 15946 |
jQuery
jQuery ( ": has (selector)")
|
| 15945 |
jQuery
attributeHas 선택자
|
| 15944 |
jQuery
.has (selector)
|
| 15942 |
jQuery
.get (index)
|
| 15941 |
jQuery
.focusin (handler)
|
| 15940 |
jQuery
.focusin (handler)
|
| 15939 |
jQuery
jQuery ( ": focus")
|
| 15938 |
jQuery
.focus (handler)
|
| 15937 |
jQuery
jQuery( ":first" )
|
| 15936 |
jQuery
jQuery ( ": first-of-type")
|
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기