Home | Top | Website design | JavaScript Editor | Get Advanced JavaScript and Ajax Editor, Validator and Debugger! 1st JavaScript Editor. |
Divides a text node at the specified index.
Syntax
oSplitNode = TextNode.splitText( [ iIndex ] )Parameters
iIndex | Optional. Integer that specifies the index of the string that indicates where the separation occurs. If a value is not provided, a new text node with no value is created. |
Return Value
Returns a text node object.
Remarks
The text node that invokes the splitText method has a nodeValue equal to the substring of the value, from 0 to iIndex . The new text node has a nodeValue of the substring of the original value, from the specified index to the value length. Text node integrity is not preserved when the document is saved or persisted.
Example
This example uses the splitText method to divide a text node in half in a ul object. When the text node splits, the createElement method creates a new li object. The appendChild method appends the new li element and the split text node to the ul object.
<SCRIPT>Standards Information
This method is defined in World Wide Web Consortium (W3C) Document Object Model (DOM) Level 1 .
Applies To
|
TextNode |
Home | Top | Website design | JavaScript Editor | Get Advanced JavaScript and Ajax Editor, Validator and Debugger! 1st JavaScript Editor. |