Created
July 4, 2011 19:14
-
-
Save clauswitt/1063805 to your computer and use it in GitHub Desktop.
Click to Split
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
function onclick(e) { | |
var range; | |
if (document.caretRangeFromPoint) { | |
range = document.caretRangeFromPoint(e.pageX, e.pageY); | |
} else if (e.rangeParent) { | |
range = document.createRange(); | |
range.setStart(e.rangeParent, e.rangeOffset); | |
} | |
var textContainer = range.startContainer; | |
var node = textContainer.parentNode; | |
var origValue = node.innerHTML; | |
var textToKeep = origValue.substr(0, range.startOffset); | |
var textToMove = origValue.substr(range.startOffset); | |
node.innerHTML = textToKeep; | |
//Do something with textToMove | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment