Question

I am writing a simple true/false maths activity using mathscribe (http://mathscribe.com/author/jqmath.html) to format my text. My questions are kept in an external js file and I then write them to the page with jquery .html()

Some code:

The questions:

Questions[0] = ["$3^2$  is called a base.", 0];
Questions[1] = ["The '3' in $4^3$ is called the exponent. ",1];

The second object in the array (0 or 1) indicates whether the answer is true or false.

This is the text im writing into my html page, the first time this is written is done like this:

<p id="questionText" align='center'><strong><script>document.write(Questions[0][0]);</script></strong></p>

Now this works fine, the formatting is shown exactly as I need it. But now the user can click on the question to show some instruction, and then click on it again to show the question again, I reload the question text with:

$("#questionText").html("<strong>"+Questions[currentQuestion][0]+"</strong>");

Once I have done this the math loses its formatting and it is shown as plain text, any idea why this is happening?

Was it helpful?

Solution

See Jqmath - apply after page load.

In your case, you could call M.parseMath($("#questionText")[0]); after reloading $("#questionText")[0].

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top