Name
Text — a run of text in a document
Inherits from
Node
Synopsis
A Text node represents a run of plain text in a document and
typically appear in the document tree as children of Element. The
textual content of a Text node is available through the data property or through the nodeValue and textContent properties
inherited from Node. You can create a new Text node with Document.createTextNode(). Text nodes
never have children.
Properties
stringdataThe text contained by this node.
readonly unsigned longlengthThe length, in characters, of the text.
readonly stringwholeTextThe text content of this node and any adjacent text nodes before or after this one. If you’ve called the
normalize()method of the parent Node, this property will be the same asdata.
Methods
Unless you are writing a web-based text editor application, these methods are not commonly used.
void appendData(string
text)
appendData(string
text)This method appends the specified
text to the end of this Text
node.
void deleteData(unsigned long
offset, unsigned long
count)
deleteData(unsigned long
offset, unsigned long
count)This method deletes characters from this Text node, starting
with the character at the position
offset and continuing for
count characters. If
offset plus
count is greater than the number of
characters in the Text node, all characters from
offset to the end of the string are
deleted.
void insertData(unsigned long
offset, string
text)
insertData(unsigned long
offset, string
text)This method inserts the specified
text into the Text node at the
specified offset.
void replaceData(unsigned long
offset, unsigned long
count, string
text
replaceData(unsigned long
offset, unsigned long
count, string
textBecome an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access