The text is in a php variable <?= $code['code'] ?>
. I just need js to insert this code inside this div.
document.write('<div id=\"editor\" class=\"editor language-<?= $opti["language"] ?>\"></div>');
If I just insert before closing </div>
, then everything flies, because it starts to be defined exactly as js code. I also tried to use the <pre>
tag, but it had no effect
The code I need to insert:
import {CodeJar} from 'codejar';
import Prism from 'prismjs';
const editor = document.querySelector("#editor");
const jar = CodeJar(editor, Prism.highlightElement, {tab: '\\t'});
// Update code
jar.updateCode('let foo = bar');
Via Active questions tagged javascript - Stack Overflow https://ift.tt/LWcxkjK
Comments
Post a Comment