Get new CodeMirror text in JavaScript

I’m running Google Chrome 81.0.4044.122 on Mac OS Catalina.

What I want is pretty simple. I just want to get the content in the CodeMirror textArea into a Javascript variable. I started with document.getElementById(“code”).value and that only gave me the value of the textArea on page load but did not include anything that I added. I removed the script that adds CodeMirror settings to the textArea (var editor = CodeMirror.fromTextArea…) and the problem was fixed, Javascript could now see changes to the textArea.

I read through the documentation, so I tried editor.getValue() and editor.getTextArea.value. These both had the same result - just the value of the text area on load and would not display any changes made in the textArea.

Has anyone had this issue? How do I do this?

Try this one again, because that should work.

Yes, it is working now, thanks for your help!