Text()

The Text() constructor returns a new Text object with the optional string given in parameter as its textual content.

Syntax

new Text();
new Text(aString);

Parameters

  • aString Optional

Return value

A new Text object containing aString, or the empty string if no parameter was given.

Example

let text = new Text("Test");

Specifications

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

Browser compatibility

BCD tables only load in the browser

See also