728x90
모든 노드들은 Node에서 상속받은 nodeType과 NodeName 프로퍼티가 존재 한다. 예를 들어 Text노드의 nodeType은 3이고 nodeName은 #text이다.
다음은 5종류의 노드에 대한 nodeType과 nodeName이다.
| node | nodeType | nodeName |
| document | 9 | #document |
| <!DOCTYPE html> | 10 | html |
| DocumentFragment | 11 | #document-fragment |
| a | 1 | A |
| text | 3 | #text |
노드가 특정 타입인지를 체크하고 싶을때 가장 빠른 방법은 nodeType을 검사하는 것이다.
'java script > DOM' 카테고리의 다른 글
| 1.8 Using JavaScript Strings to Create and Add Element and Text Nodes to the DOM (0) | 2021.08.27 |
|---|---|
| 1.7 Using JavaScript Methods to Create Element and Text Nodes (0) | 2021.08.25 |
| 1.4 Properties and Methods from Working with Nodes (0) | 2021.08.20 |
| 1.3 Subnode Objects Inherit From the Node Object (0) | 2021.08.19 |
| 1.2 Node Object Types (0) | 2021.08.18 |