I am trying to alert the content of the textarea which is used as code mirror on a button click. But it displays as blank. if i remove the script for code mirror, it displays the content.
I need to know what is wrong with using code mirror. It doesn't reflect the changes in the textarea.
<textarea id="code" name="code">
</textarea>
<input type="button" onClick="func()">
<script>
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
lineNumbers: true
});
function func() {
alert(document.getElementById('code').value);
}
</script>
Please help me out.
code
textarea. – Jai