selva_pollachi selva_pollachi - 5 months ago 30
Javascript Question

Change Height and Width of TextArea in codemirror

I am developing website which having xml, java programs. So i chose CodeMirror for displaying programs in TextArea. I had successfully displayed. It's default

height
is
300px
in
codemirror.css
. How to change Height and Width of TextArea programmatically in codemirror?

Thanks in advance.

Answer

The CodeMirror user manual is your friend.

Example code:

<textarea id="myText" rows="4" cols="10"></textarea>

<script type="text/javascript" language="javascript">
    var myTextArea = document.getElementById('myText');
    var myCodeMirror = CodeMirror.fromTextArea(myTextArea);
    myCodeMirror.setSize(500, 300);
</script>