javascript - Mathscribe 在使用 jquery 操作后丢失格式

标签 javascript jquery html css mathml

我正在使用 mathscribe ( http://mathscribe.com/author/jqmath.html ) 编写一个简单的真/假数学事件来格式化我的文本。我的问题保存在外部 js 文件中,然后我使用 jquery .html() 将它们写入页面

部分代码:

问题:

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

数组中的第二个对象(0 或 1)表示答案是真还是假。

这是我写到我的 html 页面中的文本,第一次写是这样的:

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

现在一切正常,格式完全按照我的需要显示。 但是现在用户可以点击问题来显示一些说明,然后再次点击它来再次显示问题,我重新加载问题文本:

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

完成此操作后,数学会失去其格式并显示为纯文本,知道为什么会这样吗?

最佳答案

参见 Jqmath - apply after page load .

在您的情况下,您可以调用 M.parseMath($("#questionText")[0]);重装后$("#questionText")[0] .

关于javascript - Mathscribe 在使用 jquery 操作后丢失格式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17312651/

相关文章:

javascript - 使用 node.js + functions() 连接到 MS SQL DB

php - 无法使用返回的 JSON

javascript - MongoDB 和 Node.js - 将整个模型推送到 ref 数组与推送 id 之间的区别

jquery - 使用 jQuery.ajax 发送 multipart/formdata

javascript - 从 Web 服务器访问客户端本地网络上的文件,但不能访问本地计算机上的文件

css - {位置 : sticky} in div not work if added a textfield

javascript - Bootstrap 日历的某些功能不起作用

javascript - 保存成功后启用按钮

javascript - 根据jquery对话框调整textarea的大小

javascript - 无法成功将元素从一个 div 单独拖放到另一个 div