问题
In my below code:
function test() {
document.getElementById('demo').innerHTML="$$\left[ x=0 \right] $$";//same code from demo1.but not rendered
}
test();
<script type="text/javascript" src="http://latex.codecogs.com/latexit.js"></script>
<p lang="latex"id="demo"></p>
<p lang="latex"id="demo1">$$\left[ x=0 \right] $$</p>
Same code applied from javascript. Its not rendering.kindly tell Whats wrong with my code & correct my code or give any alter suggestion for that .
Thanks in advance
回答1:
Javascript consider [\r as Carriage Return] so you have to use \\right.
function test() { document.getElementById('demo').innerHTML="$$\\left[ x=0 \\right] $$";
}
test();
<script type="text/javascript" src="http://latex.codecogs.com/latexit.js"></script>
<p lang="latex"id="demo"></p>
<p lang="latex"id="demo1">$$\left[ x=0 \right] $$</p>
来源:https://stackoverflow.com/questions/39696835/latex-not-render-when-string-call-from-javascript