alert(editor.getValue());
CodeMirror How to get Textarea value
-
01-07-2022 - |
Frage
I created a textarea to highlight text for C# code using CodeMirror. But when I try to get the value of textarea I'm failing.
I'm creating my editor as
var editor = CodeMirror.fromTextArea(document.getElementById("txtCode"), {
lineNumbers: true,
mode: "text/x-csharp",
matchBrackets: true
});
When I write some meaningless words and try to get value like this:
alert(document.getElementById("txtCode").value);
It returns:
if(true){}else{}
When I try to get it like:
alert(document.getElementById("txtCode").getValue());
The browser gives the error "Uncaught TypeError: Object # has no method 'getValue'"
How can I get this value?
Lösung
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow