Text:Text() 构造函数

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.

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

语法

js
new Text()
new Text(string)

参数

  • string 可选

返回值

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

示例

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

规范

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

浏览器兼容性

参见