splitText (W3C DOM Core method)
var text = document.getElementById('lyric').firstChild; text.splitText(28);
So if the original element was a quotation
with a single child
Text node, like this:
<q>One thing I can tell you is you've got to be free</q>
the end result of the operation above would be a quotation with two
Text nodes, the first of which has the
One thing I can tell you is , and the second has
you've got to be free.
- offset (
unsigned long) required
The character offset at which to split this node.
Text node into two nodes, at the specified character
A new node will be created as the
nextSibling of the first, containing everything from
the offset point up to the end of the string; the original node will now
contain just the text before the offset.
manipulation methods are far more flexible and powerful -
unless you specifically want to create multiple sibling
The newly created text node
No known issues.
There are no comments yet.