prasad prasad - 2 months ago 19
LaTeX Question

Latex not render when string call from javascript?

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

Answer

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>

Comments