http://jsfiddle.net/VzbYJ/86/
Please take a look at this link. Since it clears that it is going to insert the gap node into the caret place. The problem is that after inserting a node, if I click on any character, its color is also green. because it is also part of the span element. So, how can I put the caret after the interval so that the color of the next inserted node remains normal.
I tried to find the selected node (based on the caret position), set the range after the element and use collapse (false). But I could not get the desired result.
Code to search for node:
function findNode(event)
{
if (event.type == 'click')
par = event.target;
else if (event.type == 'keyup'){
if (document.selection)
par = document.selection.createRange().parentElement();
else if (window.getSelection){
var range = window.getSelection().getRangeAt(0);
par = range.commonAncestorContainer.parentNode;
}
}
, setEndAfter() ant collapse (false).
, , .
. .