Name
CharacterData — Inherits Node
Synopsis
The CharacterData
interface is a subtype of Node
that provides additional methods for working with text data. This
interface does not correspond to concrete node types, but is used as
a basis for defining the Text and
Comment interfaces.
dataThis string represents the character data held within the node.
lengthThe number of characters available through the
dataattribute andsubstringDatamethod. If the object is empty, the value may be0.appendData(arg)This method appends the string
argto the end of the character data.deleteData(offset, count)Removes a given number of characters from the character data beginning at
offsetand continuing throughoffset+count. If the supplied range exceeds the length of the string, the contents fromoffsetthrough the end of the string are deleted.insertData(offest, arg)This method allows you to insert character data into the node beginning at the position noted by
offset.replaceData(offset, count, arg)This method replaces the data beginning at offset, with the supplied data of
arg, continuing throughoffset+count. If the length of the data is exceeded, then the additional replacement text is appended to the data.substringData(offset, count)Extracts a portion of the data from the
CharacterDatanode. Ifoffset+countexceed the length, then all characters through the end of the node are returned.
Become 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