Codemirror preview - Javascript CodeMirror

Javascript examples for CodeMirror:Configuration

Description

Codemirror preview

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
      <script type="text/javascript" src="http://code.jquery.com/jquery-1.6.4.js"></script> 
      <link rel="stylesheet" type="text/css" href="https://codemirror.net/lib/codemirror.css"> 
      <script type="text/javascript" src="https://codemirror.net/lib/codemirror.js"></script> 
      <script type="text/javascript" src="https://codemirror.net/lib/overlay.js"></script> 
      <link rel="stylesheet" type="text/css" href="https://codemirror.net/theme/default.css"> 
      <script type="text/javascript" src="https://codemirror.net/mode/xml/xml.js"></script> 
      <style id="compiled-css" type="text/css">

.CodeMirror {/*from   w  w w  . j a  v  a2s. com*/
   border:1px solid #CCC;
   height:auto;
   width:500px;
}
.CodeMirror-scroll {
   height:auto;
}


      </style> 
      <script type="text/javascript">
    $(window).load(function(){
$(function () {
    $("textarea").each(function (i) {
        editor = CodeMirror.fromTextArea(this, {
             lineNumbers: true
        });
    });
});
document.getElementById('result').innerHTML=editor.getValue();
    });

      </script> 
   </head> 
   <body> 
      <textarea id="code">&lt;b&gt;Hello&lt;/b&gt;</textarea> 
      <div id="result"></div>  
   </body>
</html>

Related Tutorials