I\'m trying to read the content of a contentEditable
div and extract the currently active word. ie. the word which was just entered or one which was modified. <
I found a workaround. Previously, I was using innerHTML to get the contents.
Now, I'm using targ.firstChild.nodeValue
where targ is the element whose content is needed.Then checking with str.charCodeAt(i)==32 || str.charCodeAt(i)==160
.
This works well.
I think what you are looking is here : non-breaking space in Javascript.
String.fromCharCode(160)
worked for me. It stands for
character. if(str == ' ')
was not working in if condition, neither did trim(); but if(str == String.fromCharCode(160))
worked.
For checking normal space use if(str.trim() == '')