![](/img/trans.png)
[英]Using span tag in JavaScript to modify contents inside html <p> tags
[英]MathJax is not working properly when trying to modify the contents of the <p> tag
我一直在尝试使用 JavaScript、HTML 和 MathJax 制作 MathJax 解释器。 我已经完成了 MathJax 库等的所有默认包含,并且 web 应用程序的一个功能是能够输入一些 LaTeX 代码并在按下 a 按钮时查看 Z78E6221F6393D1356681DB398F14CEZ6。 但是,当我运行程序时,没有任何变化,所发生的只是包含output的文本框只有原始 output 输出到其中。 例如:
// My LaTeX code:
\[x=5\]
// the expected output when the button is clicked:
x = 5
// what I do get:
\[x=5\]
我已经尝试了很多东西,但我似乎无法让它发挥作用。 这是我的代码:
var input_text = document.getElementById("mathjax_input_area");
var output_p = document.getElementById("mathjax_output_area");
output_p.innerHTML = input_text.value;
MathJax.Hub.Queue(["Typeset", MathJax.Hub, 'output_p']);
有人可以帮忙吗?
当您使用MathJax.Hub.Queue(["Typeset", MathJax.Hub, string])
时,字符串应该是页面中元素的 ID,而不是代码中变量的名称。 你可以使用
MathJax.Hub.Queue(["Typeset", MathJax.Hub, output_p]);
使用实际的 DOM 元素本身(存储在变量中)或
MathJax.Hub.Queue(["Typeset", MathJax.Hub, 'mathjax_output_area']);
这样您就传递了要处理的元素的实际 ID。 要么应该工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.