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

[DOM_Element] JS - nodeType 속성 ★ - 노드타입 반환 (읽기전용) ※ 노드유형 = 노트형식 = 노드종류

목차
  1. nodeType 예제 - 노드타입 반환
  2. nodeType 정의
  3. nodeType 구문
  4. nodeType 종류
  5. nodeType 종류별 (nodeName/nodeValue) 반환
  6. nodeType 종류별 상수 이름

 

nodeType 예제 - 노드타입 반환 

 

<h1 id='hz'>홈짱닷컴 Homzzang.com</h1>


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


<p id="demo"></p>


<script>

function homzzang() {

  var x = document.getElementById("hz").nodeType;

  document.getElementById("demo").innerHTML = x;

}

</script>

 

결과값: 1

 

nodeType 정의

 

노드타입을 숫자로 반환. (읽기전용속성)

 


 

1.

  • 요소노드 경우 : 1 반환.
  • 속성노드 경우 : 2 반환.
  • 텍스트노드 경우 : 3 반환.
  • 주석노드 경우 : 8 반환.

 

2.

모든 브라우저 지원

 

3. 

DOM 버전 : Core Level 1 Node Object

 

 

nodeType 구문

 

node.nodeType

 


[반환값]

 

노드 유형 나타내는 숫자번호 반환.

 

 

nodeType 종류

Node 유형번호/의미 설명 자식
1 Element 요소 (element) Element, Text, Comment, ProcessingInstruction, CDATASection, EntityReference
2 Attr 속성 (attribute) Text, EntityReference
3 Text 요소나 속성 안의 text 문자열. None
4 CDATASection 웹문서 안 CDATA section
(parser에 의해 parse 안 되는 문자열)
None
5 EntityReference 실체값 참조 (entity reference) Element, ProcessingInstruction, Comment, Text, CDATASection, EntityReference
6 Entity 실체값 (entity) Element, ProcessingInstruction, Comment, Text, CDATASection, EntityReference
7 ProcessingInstruction 처리 지시 (processing instruction) None
8 Comment 주석 (comment) None
9 Document 전체 웹문서 (entire document)
(※ DOM tree의 root-node)
Element, ProcessingInstruction, Comment, DocumentType
10 DocumentType 문서에 대해 정의된 실체값 (entity)에 대한 인터페이스 제공 None
11 DocumentFragment 경량화 된  document 객체
(문서 일부를 담을 수 있음.)
Element, ProcessingInstruction, Comment, Text, CDATASection, EntityReference
12 Notation DTD에 선언된 표기 None

 

nodeType 종류별 (nodeName/nodeValue) 반환

Nodetype nodeName 반환값 nodeValue 반환값
1 Element 요소명 (element name) null
2 Attr 속성명 (attribute name) attribute value
3 Text #text content of node
4 CDATASection #cdata-section content of node
5 EntityReference 실체값 참조 이름(entity reference name) null
6 Entity 실체값 이름 (entity name) null
7 ProcessingInstruction target content of node
8 Comment #comment comment text
9 Document #document null
10 DocumentType doctype name null
11 DocumentFragment #document fragment null
12 Notation notation name null

 

nodeType 종류별 상수 이름

NodeType 상수명
1 ELEMENT_NODE
2 ATTRIBUTE_NODE
3 TEXT_NODE
4 CDATA_SECTION_NODE
5 ENTITY_REFERENCE_NODE
6 ENTITY_NODE
7 PROCESSING_INSTRUCTION_NODE
8 COMMENT_NODE
9 DOCUMENT_NODE
10 DOCUMENT_TYPE_NODE
11 DOCUMENT_FRAGMENT_NODE
12 NOTATION_NODE


 


분류 제목
DOM_Element JS - tabIndex 속성 - 탭색인번호 설정/반환
DOM_Element JS - tagName 속성 - 태그명 반환 (= 태그이름 반환)
DOM_Element JS - textContent 속성 ★ - 지정노드 및 그 자손노드의 텍스트내용 설정/반환 (= textCo…
DOM_Element JS - title 속성 - 타이틀 속성값 설정/반환 (= title속성 = 타이틀속성)
DOM_Element JS - toString() 메서드 -
DOM_Event JS - abort 이벤트 (= onabort 속성) - 미디어로드중단 (= 온어보트이벤트, IE9)
DOM_Event JS - afterprint 이벤트 (= onafterprint 속성) - 인쇄모드이벤트 (= 인쇄시작 / …
DOM_Event JS - animationend 이벤트 (= onanimationend 속성) - 애니완료이벤트 (= 애니종…
DOM_Event JS - animationiteration 이벤트 (= onanimationiteration 속성) - CS…
DOM_Event JS - animationstart 이벤트 (= onanimationstart 속성) - CSS 애니메인션 …
DOM_Event JS - beforeprint 이벤트 (= onbeforeprint 속성) - 인쇄모드 인쇄대화상자 나타나기…
DOM_Event JS - beforeunload 이벤트 (= onbeforeunload 속성) - 웹문서 언로드 (= 사이트…
DOM_Event JS - blur 이벤트 (= onblur 속성) - 포커스제거이벤트 (= 포커스해제이벤트 = 블러이벤트)
DOM_Event JS - canplay 이벤트 (= oncanplay 속성) - 동영상재생가능 (= 비디오재생가능/오디오재생…
DOM_Event JS - canplaythrough 이벤트 (= oncanplaythrough 속성) - 버퍼링중지없이 재생…
DOM_Event JS - change 이벤트 (= onchange 속성) ★ - 요소값변경이벤트 (= 체인지이벤트 = 온체인…
DOM_Event JS - click 이벤트 (= onclick속성 = 온클릭이벤트) ★ - 마우스클릭이벤트
DOM_Event JS - contextmenu 이벤트 (oncontextmenu 속성) - 마우스오른쪽메뉴선택 (= 컨텍스트…
DOM_Event JS - copy 이벤트 (= oncopy 속성) - 복사이벤트 (= copy이벤트 = 카피이벤트) ※ 복사…
DOM_Event JS - cut 이벤트 (= oncut 속성) - 잘라내기이벤트 (= 컷이벤트)
31/67
목록
찾아주셔서 감사합니다. Since 2012