Detect   and space with JavaScript

前端 未结 3 1395
忘了有多久
忘了有多久 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 18:03

    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() == '')

提交回复
热议问题