textNode.splitText() (Method)

A means of splitting the text in a text node into two so that HTML can be placed in between them.

Availability:

DOM level - 1
JavaScript - 1.5
JScript - 5.0
Internet Explorer - 5.0
Netscape - 6.0
Property/method value type:textNode object
JavaScript syntax:-myTextNode.splitText(anOffset)
Argument list:anOffsetThe location within the text data to split the text at

This is functionally similar to splitting a String object. The character index, using a zero-based counting scheme where the split is to occur, should be passed as an argument.

The method returns the text to the right of the split. The receiving object is truncated at the split point. You can then append some HTML to the receiving object and then append the text object that was returned by the method.