Created
January 13, 2016 11:25
-
-
Save ktkaushik/c0954dfd60369c1b138e to your computer and use it in GitHub Desktop.
Split text among nodes in POJS.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var node = Util.getSelectionStart() | |
var text = p.childNodes[0]; | |
var at = 5; | |
// create new span node with content | |
var span = document.createElement("span"); | |
span.appendChild(document.createTextNode('ipsum')); | |
// Split the text node into two and add new span | |
p.insertBefore(span, text.splitText(at)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment