Please have a look at this link. As it clears that it is going to insert a span node at the caret place. Problem is,after inserting the node if I am pressing any character its color is also green. because it is also coming inside the span element. So how can I put the caret after the span so that the color of next inserted node remains normal.
I tried to find the selected node (based on to caret position), set the range after the element and used collapse(false). But I could not get the desired output.
Code for find the 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;
}
}
and next I set the boundary using setEndAfter() ant collapse(false). I am new in this field so I am not sure that what extend I am right. So any suggestion is very much appreciable. Thanks in advance.