Name
Text — a run of text in an HTML or XML document
Availability
DOM Level 1 Core
Inherits from/Overrides
Node → CharacterData → Text
Subinterfaces
CDATASection
Methods
-
splitText( )
Splits this Text node into two at the specified character position and returns the new Text node.
Description
A Text node represents a run of plain text in an HTML or XML
document. Plain text appears within HTML and XML elements and
attributes, and Text nodes typically appear as children of Element
and Attr nodes. Text nodes inherit from CharacterData, and the
textual content of a Text node is available through the
data
property inherited from CharacterData or
through the nodeValue
property inherited from
Node. Text nodes may be manipulated using any of the methods
inherited from CharacterData or with the splitText( )
method defined by the Text interface itself. Text nodes
never have children.
See Node.normalize( ) for a way to remove empty Text nodes and merge adjacent Text nodes from a subtree of a document.
Get JavaScript: The Definitive Guide, Fourth Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.