web api interface
CharacterData
The CharacterData abstract interface represents a Node object that contains characters. This is an abstract interface, meaning there aren’t any objects of type CharacterData: it is implemented by other interfaces like Text, Comment, CDATASection, or ProcessingInstruction, which aren’t abstract.
Instance properties
This interface also inherits properties from its parents, Node and EventTarget.
data- : A string representing the textual data contained in this object.
lengthRead only- : Returns a number representing the size of the string contained in the object.
nextElementSiblingRead only- : Returns the first
Elementthat follows this node, and is a sibling.
- : Returns the first
previousElementSiblingRead only- : Returns the first
Elementthat precedes this node, and is a sibling.
- : Returns the first
Instance methods
This interface also inherits methods from its parents, Node and EventTarget.
after()- : Inserts a set of
Nodeobjects or strings in the children list of theCharacterData’s parent, just after theCharacterDataobject.
- : Inserts a set of
appendData()- : Appends the given string to the
CharacterData.datastring; when this method returns,datacontains the concatenated string.
- : Appends the given string to the
before()- : Inserts a set of
Nodeobjects or strings in the children list of theCharacterData’s parent, just before theCharacterDataobject.
- : Inserts a set of
deleteData()- : Removes the specified amount of characters, starting at the specified offset, from the
CharacterData.datastring; when this method returns,datacontains the shortened string.
- : Removes the specified amount of characters, starting at the specified offset, from the
insertData()- : Inserts the specified characters, at the specified offset, in the
CharacterData.datastring; when this method returns,datacontains the modified string.
- : Inserts the specified characters, at the specified offset, in the
remove()- : Removes the object from its parent children list.
replaceData()- : Replaces the specified amount of characters, starting at the specified offset, with the specified string; when this method returns,
datacontains the modified string.
- : Replaces the specified amount of characters, starting at the specified offset, with the specified string; when this method returns,
replaceWith()- : Replaces the characters in the children list of its parent with a set of
Nodeobjects or strings.
- : Replaces the characters in the children list of its parent with a set of
substringData()- : Returns a string containing the part of
CharacterData.dataof the specified length and starting at the specified offset.
- : Returns a string containing the part of
Specifications
SpecificationsStandards references are available on the canonical MDN page.
Browser compatibility
Browser compatibilityCompatibility data is available on the canonical MDN page.
See also
- The DOM overview page.
- The concrete interfaces implemented it:
Text,CDATASection,ProcessingInstruction, andComment.