[ Web Proxy ]
URL:
Viewing: https://developer.mozilla.org/ja/docs/Web/API/Node/nodeType [Back]  [Original]

Node: nodeType - Web API | MDN

MDN Web Docs

View in English Always switch to English

Node: nodeType

Baseline

20157

nodeType Node elementstextcomments

Node.ELEMENT_NODE (1)

<p> <div> Element

Node.ATTRIBUTE_NODE (2)

Element Attribute

Node.TEXT_NODE (3)

Element Attr Text

Node.CDATA_SECTION_NODE(4)

<!CDATA[[ ]]> CDATASection

Node.PROCESSING_INSTRUCTION_NODE (7)

<?xml-stylesheet ?> XML ProcessingInstruction

Node.COMMENT_NODE (8)

<!-- --> Comment

Node.DOCUMENT_NODE (9)

Document

Node.DOCUMENT_TYPE_NODE (10)

<!DOCTYPE html> DocumentType

Node.DOCUMENT_FRAGMENT_NODE (11)

DocumentFragment

Node.ENTITY_REFERENCE_NODE (5), Node.ENTITY_NODE (6), Node.NOTATION_NODE (12)

js
document.nodeType === Node.DOCUMENT_NODE; // true
document.doctype.nodeType === Node.DOCUMENT_TYPE_NODE; // true

document.createDocumentFragment().nodeType === Node.DOCUMENT_FRAGMENT_NODE; // true

const p = document.createElement("p");
p.textContent = "";

p.nodeType === Node.ELEMENT_NODE; // true
p.firstChild.nodeType === Node.TEXT_NODE; // true

js
const node = document.documentElement.firstChild;
if (node.nodeType !== Node.COMMENT_NODE) {
  console.warn("");
}

DOM
# ref-for-dom-node-nodetype


Web Proxy Viewer  |  New URL  |  Original Page