You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: node-properties.md
+50-19Lines changed: 50 additions & 19 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -569,32 +569,40 @@ properties. Or explore “DOM properties” in the Elements tab of the browser d
569
569
570
570
<p>Main DOM node properties are:</p>
571
571
572
+
<mark>nodeType</mark>
573
+
<p>We can use it to see if a node is a text or an element node. It has a numeric value:
574
+
<mark>1</mark> for elements,<mark>3</mark> for text nodes, and a few others for other
575
+
node types. Read-only.</p>
572
576
573
-
nodeType
574
-
We can use it to see if a node is a text or an element node. It has a numeric value: 1 for elements,3 for text nodes, and a few others for other node types. Read-only.
577
+
<mark>nodeName/tagName</mark>
578
+
<p>For elements, tag name (uppercased unless XML-mode). For non-element nodes <mark>nodeName</mark>
579
+
describes what it is. Read-only.</p>
575
580
576
-
nodeName/tagName
577
-
For elements, tag name (uppercased unless XML-mode). For non-element nodes nodeName describes what it is. Read-only.
581
+
<mark>innerHTML</mark>
582
+
<p>The HTML content of the element. Can be modified.</p>
578
583
579
-
innerHTML
580
-
The HTML content of the element. Can be modified.
584
+
<mark>outerHTML</mark>
585
+
<p>The full HTML of the element. A write operation into <mark>elem.outerHTML</mark> does not
586
+
touch elem itself. Instead it gets replaced with the new HTML in the outer context.</p>
581
587
582
-
outerHTML
583
-
The full HTML of the element. A write operation into elem.outerHTML does not touch elem itself. Instead it gets replaced with the new HTML in the outer context.
588
+
<mark>nodeValue/data</mark>
589
+
<p>The content of a non-element node (text, comment). These two are almost the same, usually we use data. Can be modified.</p>
584
590
585
-
nodeValue/data
586
-
The content of a non-element node (text, comment). These two are almost the same, usually we use data. Can be modified.
591
+
<mark>textContent</mark>
592
+
<p>The text inside the element: HTML minus all <mark><tags></mark>. Writing into it
593
+
puts the text inside the element, with all special characters and tags treated exactly as
594
+
text. Can safely insert user-generated text and protect from unwanted HTML insertions.</p>
587
595
588
-
textContent
589
-
The text inside the element: HTML minus all <tags>. Writing into it puts the text inside the element, with all special characters and tags treated exactly as text. Can safely insert user-generated text and protect from unwanted HTML insertions.
596
+
<mark>hidden</mark>
597
+
<p>When set to <mark>true</mark>, does the same as <mark>CSS display:none</mark>.</p>
590
598
591
-
hidden
592
-
<p>When set to true, does the same as CSS display:none.</p>
593
-
594
-
<p>DOM nodes also have other properties depending on their class. For instance, <input> elements (HTMLInputElement) support value, type, while <a> elements (HTMLAnchorElement) support href etc. Most standard HTML attributes have a corresponding DOM property.</p>
599
+
<p>DOM nodes also have other properties depending on their class. For instance,
600
+
<mark><input></mark> elements <mark>(HTMLInputElement)</mark> support
601
+
<mark>value</mark>, <mark>type</mark>, while <mark><a></mark> elements
602
+
<mark>(HTMLAnchorElement)</mark> support <mark>href</mark> etc. Most standard
603
+
HTML attributes have a corresponding DOM property.</p>
595
604
596
605
<p>However, HTML attributes and DOM properties are not always the same, as we’ll see in the next chapter.</p>
0 commit comments