简体   繁体   English

用jQuery处理后Mathscribe失去格式

[英]Mathscribe loses formatting after manipulation with jquery

I am writing a simple true/false maths activity using mathscribe ( http://mathscribe.com/author/jqmath.html ) to format my text. 我正在使用mathscribe( http://mathscribe.com/author/jqmath.html )编写简单的对/错数学活动来设置文本格式。 My questions are kept in an external js file and I then write them to the page with jquery .html() 我的问题保存在外部js文件中,然后使用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. 数组中的第二个对象(0或1)指示答案是对还是错。

This is the text im writing into my html page, the first time this is written is done like this: 这是即时消息写到我的html页面中的文本,第一次编写是这样的:

<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? 完成此操作后,数学将失去其格式,并以纯文本形式显示,您知道为什么会这样吗?

See Jqmath - apply after page load . 请参阅Jqmath-页面加载后应用

In your case, you could call M.parseMath($("#questionText")[0]); 在您的情况下,您可以调用M.parseMath($("#questionText")[0]); after reloading $("#questionText")[0] . 重新加载$("#questionText")[0]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM