This is my code to implement Mathjax.
<head>
<script src='https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML'></script>
<script type="text/x-mathjax-config">
MathJax.Hub.Config({
tex2jax: { inlineMath: [['$', '$']] },
elements: ['math']
});
</script>
</head>
This is my code to add another math expression into the html
function dumpElement(blockIdentifier, questionNumber, data){
document.getElementById(blockIdentifier).innerHTML += `<p style= "float:left; left:0%;">` + (questionNumber + ')') + `</p>
<p id = "math">` + data + `</p> <br><br><br><br>`;
}
After the page initially loads and this function is invoked, I cannot get the "data," a latex encoded string, to be displayed properly. For example, here is an element I copied using the inspect element.
<p id="math">$\frac{37}{40}$</p>
What's EVEN MORE INTERESTING is that the following html tag is statically typed into the html (that is, it will be displayed before function dumpElement() ) and properly displays!
<p id="math">$-\frac{2}{3}$</p>
What should I do to get the dynamically printed html tags to display correctly? Thanks.