0

I want to know the last word written or pasted on summernote, below is the code I am using for the same

onkeyup: function (e) {


              //  CurrentContent = $('#summernote').code();
                var CurrentContent = $('#summernote').code().replace(/(<([^>]+)>);/ig, "");
                if (e.keyCode == 32) {
                    PrevContent = CurrentContent.replace(PrevContent, "");

                    $('#content').text(PrevContent);
                    PrevContent = CurrentContent;
                }

                console.log('Key is released:', e.keyCode);
            }



<div id="summernote"></div>
 <h1>Latest word:</h1>
<div id="content"> </div>

This is not giving me correct result; instead it is giving me something like this when I am typing "Test "

<p>Test&nbsp;</p>

How can i fix it? sorry for my bad english

4

1 回答 1

0

要获得最新的单词,只需使用:

var latestword = $('#summernote').text().split(/(\s|&nbsp;)/).pop();

由于您没有提供任何 html 我不知道是否是.text()正确的功能,将其替换为.html()或其他.code()

于 2014-09-05T15:07:30.430 回答