CodeMirror without Textarea

- Written by

Last modified April 5, 2018

CodeMirror without Textarea to < / pre > [ tag ]

Possible? why apply without a Textarea? Let's say that it is not required, however it simplifies and not just its use. Here's is, how to apply on a < / pre > Element Tag:

<pre><code>Your HTML / CSS / JavaScript here...</code></pre>
/* Live CodeMirror to < / pre >
* @webbeloz
* 
**/
var c = document.getElementsByTagName("pre"),
  ce = c[0],
  textHtml = ce.textContent || ce.innerText || ce.innerHTML,
  heditor = CodeMirror(function(node){ce.parentNode.replaceChild(node, ce);}, {
    value: textHtml,
    mode: "text/html",
    htmlMode: true,
    theme: "default",
    lineNumbers: true,
    lineWrapping: true
    // & m.more...
  });

Demo? Yess. All Instance of each / CodeMirror Editors is now inside a TAG
 [ </pre></code> ] 

[ Live Now... ] @ CodePlay Live Code Editors: CodePlay.it

@webbeloz

 4
ร—

Time expired..
- default (90 days)
- edit to (∞ days)
- Spamm Check

Leave a Comment

* Required: Name, eMail, Comment Emoji? : if(name) => start.eMail if(eMail) => start.Comment + Emoji (On/Off) ? a=* b=* c=31 (a + b = c) => Post a Comment enjoy(: tnx_wblz
OFF
ON
Check Url & "Not Allowed"
No Text /HTML