I have a bit of code where I am updating some of the variables in a mathJax equation in javascript. It works fine on the first pass (i.e. refreshing the page), but when I update the variables on a second pass, the equation is shown as Latex code instead of the rendered equation.
document.getElementById("sumstdeveq").innerHTML="$$ \\sqrt{("+stdev1+")^2+("+stdev2+")^2} $$";
This line works fine on the first pass, but when I update stdev1 and stdev2 and run this line again, it just shows the code.
Here is a fiddle: https://jsfiddle.net/yangchris16/k8us0hLt/6/
change the value in one of the input text boxes.
I'm not too clued up on MathJax but adding the following line worked on the fiddle.
MathJax.Hub.Queue(["Typeset",MathJax.Hub,this.formula]);
Right after the line you mentioned:
stdev1=0.2;
stdev2=0.05;
updatecalcs();
function updatecalcs(){
stdev1=parseFloat(document.getElementById("stdev1in").value);
stdev2=parseFloat(document.getElementById("stdev2in").value);
document.getElementById("sumstdeveq").innerHTML="$$ \\sqrt{("+stdev1+")^2+("+stdev2+")^2} $$";
MathJax.Hub.Queue(["Typeset",MathJax.Hub,this.formula]);
}