Text: Text() constructor
The Text() constructor returns a new Text object
with the optional string given in parameter as its textual content.
Syntax
js
new Text()
new Text(string)
Parameters
stringOptional
Return value
A new Text object with the content of the string parameter, or the empty string if no parameter was given.
Example
js
let text = new Text("Test");
Specifications
| Specification |
|---|
| DOM Standard # ref-for-dom-text-text① |
Browser compatibility
| desktop | mobile | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
Text() constructor | |||||||||||
See also
- The DOM API