Text()
Text()
构造方法返回一个最新创建的Text
(en-US) 对象,该对象带有可选参数 DOMString
作为文本节点的文本内容 (textual content)。
Syntax
text1 = new Text(); // 创建一个空的文本节点 (text node),即它的 textContent 为空字符 text2 = new Text("This is a text node");//该构造方法参数作为文本节点的 textContent 的值。
Example
js
text = new Text("Test");
Specifications
Specification |
---|
DOM Standard # ref-for-dom-text-text① |
Browser compatibility
BCD tables only load in the browser