mangar - 3 months ago 12

LaTeX Question

I have one simple Mathjax code:

`<!DOCTYPE html>`

<html>

<head>

<script type="text/javascript"

src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML">

</script>

<script>

var ok = function ()

{

document.getElementById('demo').innerHTML="$$10\\x^2$$"

}

</script>

</head>

<body>

<button onclick="ok()">Click</button>

<p id="demo1">Within html $$10\\x^2$$</p>

<p id="demo"></p>

</body>

</html>

I was applied from direct html the Tex was converting.But applied from javascript its not rendering.What should i do.I was search with google but not getting answer.

I need to apply the latex code from javascript It will be rendered with Tex format.Anyone help me to solve my problem.Please give a code its more help full for me.

Thank you.

Answer

```
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript"
src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML">
</script>
<script>
var ok = function ()
{
document.getElementById('demo').innerHTML="$$10\\x^2$$"
MathJax.Hub.Queue(["Typeset",MathJax.Hub]);
}
</script>
</head>
<body>
<button onclick="ok()">Click</button>
<p id="demo1">Within html $$10\\x^2$$</p>
<p id="demo"></p>
</body>
</html>
```

The result is not exactly the same :/ But your problem is MathJax doesn't refresh when you change data dynamically.

Maybe take a look here : https://github.com/mathjax/MathJax/blob/master/test/sample-dynamic.html

I don't know this lib, can't help you more.