splitText

fun splitText(offset: Int): Text(source)

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.

MDN Reference