There is a textarea id = "textarea-id". The text editor CodeMirror is used. To activate it, use this appeal:

var editor = CodeMirror.fromTextArea(document.getElementById("textarea-id"), { lineNumbers: true, matchBrackets: true, mode: "application/x-httpd-php", indentUnit: 4, theme: "base16-light", indentWithTabs: true, styleActiveLine: true, lineWrapping: true, tabSize: 4 }); 

Further, the composition of this textarea must be removed, but it does not see changes

 $("button").on("click", function(){ alert($("textarea").val()); }); 

and just prints an empty string. I tried to cut the connection CodeMirror, immediately helped, but without it in any way. What can be done?

    1 answer 1

     var editor = CodeMirror.fromTextArea( document.getElementById("textarea-id"), { ... }); editor .on("change", function(cm) { $("#textarea-id").val(cm.getValue()); }); $("button").on("click", function() { console.log($('#textarea-id').val()); }); 
    • Thank you very much!!! - Daniel Sazonov