I am developing a project using codemirror in an aspx page. Here is my code:
<form><textarea id="code" name="code" >
<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 ?
If you want to set the value of a CodeMirror there's the .setValue method:
function app() {
var txt = "myText";
editor.setValue(txt);
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.