Is there a way to get the next character after window.getSelection ()? I need to check if the character after the selected text is a space or not ...
EDIT: Thanks for your answers! I mainly use this link to highlight text, but would like to limit all words. I used the solution presented below (by Stephen) as a starting point; I think the following should work:
sel = window.getSelection(); var text = sel.anchorNode.nodeValue; var index = sel.baseOffset + sel.focusOffset-1; var isSpace = text[index] === undefined; if (isSpace) { alert("space"); }
(In the link above, I used this code immediately after calling makeEditableAndHighlight).
Eric source share