Put text from variable into codemirror textarea
===

I am developing a project using codemirror in an aspx page. Here is my code: 

    <form><textarea id="code" name="code" >

</textarea>
<input type="button" onclick="app()" /> 

</form>


    <script type="text/javascript">
      
        var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
            lineNumbers: true,
            matchBrackets: true,
            mode: "text/x-csharp"
        });
        function app() {
            
            var txt = "myText";
            $('textarea#code').text(txt);
        }
    </script>

So i want every time that i am pushing the button i want to put the value of the variable txt into the codemirror's text area. Instead when i am clicking it nothing happens to the text area. Any help pls ?