JavaScript

[DOM_Element] JS - querySelectorAll() 메서드 - Element객체의 쿼리선택자_전부 (= 쿼리선택자_모두) (IE9)

querySelectorAll() 예제

 

<style>

#hz {

  border: 1px solid black;

}

</style>


<div id="hz">

  <h2 class="sinbi">홈짱닷컴</h2>

  <p class="sinbi">Homzzang.com</p> 

</div>


<button onclick="homzzang()">클릭</button>


<script>

function homzzang() {

  var x = document.getElementById("hz").querySelectorAll(".sinbi");

  x[0].style.backgroundColor = "yellow";

}

</script>

 

결과보기

※ node 색인번호는 0부터 시작.

※ x.length : 2

※ 지정선택자와 일치하는 모든자식요소 노드리스트객체 반환.

 


분류 제목
Window_Object JS - window 객체 - 윈도우객체 (속성/메서드) 종류
API_Storage JS - Storage Object - 스토리지 객체 (※ 데이터 저장소)
Object JS - Object Constructor - 객체생성자종류 ★
Object JS - Object Prototypes - 객체프로토타입 (= 객체원형) ★
Object JS - object ECMAScript 5 - 객체혁명
DOM_Attribute JS - attr.isId -
DOM_Attribute JS - attr.name -
DOM_Attribute JS - attr.value -
DOM_Attribute JS - attr.specified -
DOM_Attribute JS - nodemap.getNamedItem() 메서드 -
DOM_Attribute JS - nodemap.item() 메서드 -
DOM_Attribute JS - nodemap.length -
DOM_Attribute JS - nodemap.removeNamedItem() 메서드 -
DOM_Attribute JS - nodemap.setNamedItem() 메서드 -
Window_Console JS - console.assert() 메서드 - 표현식이 FALSE인지 확인 (= 표현식 거짓 여부 체크 …
30/89
목록
 홈  PC버전 로그인 일본어
그누앞단언어
그누뒷단언어
그외코딩언어
그누보드
제작의뢰
Q&A
커뮤니티 3
웹유틸
회원센터
홈짱닷컴 PC버전 로그인