MPorto MPorto - 1 year ago 80
Javascript Question

Retrieving current text inside editable span tag

I am using Summernote ( to create an editor where users can edit a message they have created. Inside the text shown in the editor when the page loads, I have a few

tags that wrap some sections of the message, and each of these has a different id (for example,
<span id="something">

When the user presses the save button, I want to retrieve the text inside each
tag at that moment. I tried using something like
, but that only retrieves the text that was inside the spans when the page was loaded, not the current text. Any ideas how to fix this?

Answer Source

The summernote, create another span, if you use id you get the text of the element with display:'none', try to use class and get the last element

$(document).ready(function() {
  $('.save').on('click', function() {
    return false;

See the Plunker