Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to get the output in a div when a textarea is modified?
    text
    copied!<p>I have used the below method to see the output whena textarea area is modified, it works fine. But i would like to use the Codemirror as the textarea, when i insert any data in codemirror textarea then the output should appear the div .</p> <pre><code>&lt;script type="text/javascript"&gt; function updateDisplay() { document.getElementById("code").innerHTML = document.getElementById("entry").value; } &lt;/script&gt; &lt;textarea onkeyup="updateDisplay();" name="entry" id="entry" cols="1000" rows="500"&gt;&lt;/textarea&gt; &lt;div name="code" id="code" &gt;&lt;/div&gt; </code></pre> <p>CodeMirror</p> <pre><code> &lt;link rel="stylesheet" href="http://codemirror.net/lib/codemirror.css"&gt; &lt;script src="http://codemirror.net/lib/codemirror.js"&gt;&lt;/script&gt; &lt;script src="http://codemirror.net/mode/xml/xml.js"&gt;&lt;/script&gt; &lt;script src="http://codemirror.net/mode/javascript/javascript.js"&gt;&lt;/script&gt; &lt;script src="http://codemirror.net/mode/css/css.js"&gt;&lt;/script&gt; &lt;script src="http://codemirror.net/mode/htmlmixed/htmlmixed.js"&gt;&lt;/script&gt; &lt;textarea id="code" name="code"&gt; &lt;html style="color: green"&gt; &lt;!-- this is a comment --&gt; &lt;style type="text/css"&gt; h1 {font-family: comic sans; color: #f0f;} div {background: yellow !important;} body { max-width: 50em; margin: 1em 2em 1em 5em; } &lt;/style&gt; &lt;/head&gt; &lt;body&gt; &lt;script&gt; function jsFunc(arg1, arg2) { if (arg1 &amp;&amp; arg2) document.body.innerHTML = "achoo"; } &lt;/script&gt; &lt;/body&gt; &lt;/html&gt; &lt;/textarea&gt;&lt;/form&gt; &lt;script&gt; var editor = CodeMirror.fromTextArea(document.getElementById("code"), {mode: "text/html", tabMode: "indent"}); &lt;/script&gt; </code></pre> <p> </p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload