Search Results
DOMText::splitText — Coupe le nœud en deux nœuds à l'endroit spécifié
Dom\Text::splitText (PHP 8 >= 8.4.0) Dom\Text::splitText — Breaks this node into two nodes at the specified offset
- Overview
- Syntax
- Example
- Browser compatibility
- See also
The splitText() method of the Text interface breaks the Text node into two nodes at the specified offset, keeping both nodes in the tree as siblings.
After the split, the current node contains all the content up to the specified offset point, and a newly created node of the same type contains the remaining text. The newly created node is returned to the caller. If the original node had a parent, the new node is inserted as the next sibling of the original node. If the offset is equal to the length of the original node, the newly created node has no data.
Parameters
offset The index immediately before which to break the text node.
Return value
Returns the newly created Text node that contains the text after the specified offset point.
Exceptions
IndexSizeError DOMException Thrown if the specified offset is negative or is greater than the number of 16-bit units in the node's text. NoModificationAllowedError DOMException Thrown if the node is read-only.
In this example, the text of a
is split into two text nodes, and a is inserted between them.
BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.
•The Text interface it belongs to.
•The opposite method: Node.normalize.
Jun 21, 2023 · The splitText () method breaks the Text node into two nodes at the specified offset index, keeping both nodes in the tree as siblings. After Splitting the text, the main node contains all the content up to the specified offset index point, and a newly created node of the same type contains the remaining text. Syntax: newTextNode=textNode.splitText(offsetIndex) Parameters: offset index: The ...
Usage This method removes from the current node the second part of the text. This method returns the second part of the text but does not place it in the DOM. You must, for example, append the new text node with appendChild in DOMNode.
--- --- ## Definition and Usage The `splitText()` method splits a text node into two nodes at the specified offset. This function returns the node
Learn more about the WebKit.DomText.SplitText in the WebKit namespace.
