第337页 The Text Type
byhard (byhard.com)
- 章节名:The Text Type
- 页码:第337页
nodeType is 3. nodeName is “#text”. nodeValue is text contained in the node. parentNode is an Element. Child nodes are not supported. appendData(text) — Appends text to the end of the node. deleteData(offset, count) — Deletes count number of characters starting at position offset. insertData(offset, text) — Inserts text at position offset. replaceData(offset, count, text) — Replaces the text starting at offset through offset + count with text. splitText(offset) — Splits the text node into two text nodes separated at position offset. substringData(offset, count) — Extracts a string from the text beginning at position offset and continuing until offset + count. <!-- no content, so no text node --> <div></div> <!-- white space content, so one text node --> <div> </div> <!-- content, so one text node --> <div>Hello World!</div> 检索:var textNode = div.firstChild; //or div.childNodes[0] 更改:div.firstChild.nodeValue = “Some other message”; //outputs as “Some <strong>other</strong> message” div.firstChild.nodeValue = “Some <strong>other</strong> message”; Creating Text Nodes document.createTextNode() var textNode = document.createTextNode(“<strong>Hello</strong> world!”); var element = document.createElement(“div”); element.className = “message”; var textNode = document.createTextNode(“Hello world!”); element.appendChild(textNode); document.body.appendChild(element);
byhard对本书的所有笔记 · · · · · ·
-
第316页 The Document Type
nodeType is 9. nodeName is “#document”. nodeValue is null. parentNode is null. ownerD...
-
第326页 The Element Type
nodeType is 1. nodeName is the element’s tag name. nodeValue is null. parentNode may b...
-
第337页 The Text Type
-
第341页 Dom Types
-
第346页 Dynamic Scripts
external JavaScript file: function loadScript(url){ var script = document.createEleme...
说明 · · · · · ·
表示其中内容是对原文的摘抄