| [ Web Proxy ] |
| Viewing: https://developer.mozilla.org/docs/Web/API/Text | [Back] [Original] |
Get to know MDN better
This feature is well established and works across many devices and browser versions. Its been available across browsers since July 2015.
* Some parts of this feature may have varying levels of support.
The Text interface represents a text node in a DOM tree.
To understand what a text node is, consider the following document:
<html lang="en" class="e">
<head>
<title>Aliens?</title>
</head>
<body>
Why yes.
</body>
</html>
In that document, there are five text nodes, with the following contents:
"\n " (after the <head> start tag, a newline followed by four spaces)"Aliens?" (the contents of the title element)"\n " (after the </head> end tag, a newline followed by two spaces)"\n " (after the <body> start tag, a newline followed by two spaces)"\n Why yes.\n \n\n" (the contents of the body element)Each of those text nodes is an object that has the properties and methods documented in this article.
Text()Returns a new Text node with the parameter as its textual content.
Inherits properties from its parents, CharacterData, Node, and EventTarget.
Text.assignedSlot Read onlyReturns a HTMLSlotElement representing the <slot> the node is inserted in.
Text.wholeText Read onlyReturns a string containing the text of all Text nodes logically adjacent to this Node, concatenated in document order.
Inherits methods from its parent, CharacterData, Node, and EventTarget.
Text.splitTextBreaks the node into two nodes at a specified offset.
| Specification |
|---|
| DOM # interface-text |
This page was last modified on Feb 19, 2023 by MDN contributors.
TextAbortControllerAbortSignalAbstractRangeAttrCDATASectionCharacterDataCommentCustomEventDOMErrorDOMExceptionDOMImplementationDOMParserDOMTokenListDocumentDocumentFragmentDocumentTypeElementEventEventTargetHTMLCollectionMutationObserverMutationRecordNamedNodeMapNodeNodeIteratorNodeListProcessingInstructionQuotaExceededErrorRangeShadowRootStaticRangeTreeWalkerXMLDocumentXPathEvaluatorXPathExpressionXPathResultXSLTProcessorYour blueprint for a better internet.
Portions of this content are 19982026 by individual mozilla.org contributors. Content available under a Creative Commons license.
| Web Proxy Viewer | New URL | Original Page |