How to get the plain text from summernote editor?

John Smith picture John Smith · Apr 9, 2015 · Viewed 40.3k times · Source

for example, this is what I entered:

sdf
42342
xxcv

.code() converts it to sdf<br>42342<br>xxcv

or another thing:

[{"_type":"ServerOperation","operationType":"ANNOUNCE"}]

becames

<span class="message_content">[{"_type":"ServerOperation","operationType":"ANNOUNCE"}]</span>

how to get the pure / plain text?

Answer

Dilshod Zopirov picture Dilshod Zopirov · Jun 22, 2016

Just try this:

var plainText = $($("#summernote").code()).text()

EDIT: In newer versions you need use this instead:

var plainText = $($("#summernote").summernote("code")).text()