Text:Text() 构造函数

Text() 构造函数返回一个新创建的 Text 对象,其文本内容为参数中给出的可选字符串。

语法

js
new Text()
new Text(string)

参数

  • string 可选

返回值

一个新的 Text 对象,包含参数 string 的内容,如果没有给定参数,则为空字符串。

示例

js
let text = new Text("Test");

规范

Specification
DOM Standard
# ref-for-dom-text-text①

浏览器兼容性

BCD tables only load in the browser

参见