Latest web development tutorials

XML DOM splitText () method

Text Object Reference Text objects

Definition and Usage

splitText () method in accordance with the specified offset the text node into two nodes.

This function returns the text node contains the offset later.

Before offset of the text remains in the original text node.

grammar

splitText(offset)

参数 描述
offset 必需。规定在何处分割文本节点。偏移值以 0 开始。


Examples

The following code fragment uses loadXMLDoc () to " the Books.xml " into xmlDoc, and after the first word in a text node segmentation:

Examples

xmlDoc=loadXMLDoc("books.xml");

x=xmlDoc.getElementsByTagName("title")[0].childNodes[0];
y=x.splitText(9);

document.write(x.nodeValue);
document.write("
");
document.write(y.nodeValue);

Output:

Everyday
Italian

try it"

Text Object Reference Text objects