Detect   and space with JavaScript

前端 未结 3 1405
忘了有多久
忘了有多久 2021-01-18 16:59

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. <

3条回答
  •  后悔当初
    2021-01-18 17:44

    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.

提交回复
热议问题