我正在尝试使用MathJax将在 HTML 文本框中输入的方程(在 Tex 中)查看为数学方程。如果方程没有正确查看,我需要在数学方程中编辑方程并查看它。
第一次,它工作正常。但在执行编辑后,Mathjax 排版命令显示错误。要求您通过它,并提出可能的错误。
我使用的 HTML 是:
<html>
<head>
<title>
Equation Edit
</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<script src="https://polyfill.io/v3/polyfill.min.js?features=es6"></script>
<script id="MathJax-script" async src="https://cdn.jsdelivr.net/npm/mathjax@3.0.0/es5/tex-mml-chtml.js"></script>
</head>
<body>
<strong> Here is the result :<br></strong>
<input type="text" id=input value="\(ax^2 + bx + c = 0\)">
<div id="qPreview"></div>
<button id="check">Click</button>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
我使用的脚本是:
<script type="text/javascript">
var eq;
$("#check").click(function(){
eq=document.getElementById("input").value;
document.getElementById("qPreview").innerHTML=eq;
MathJax.typeset(qPreview[0]);
});
</script>
Run Code Online (Sandbox Code Playgroud)
当我单击按钮时,它第二次显示以下错误:
未捕获的类型错误:无法在 l.append (tex-mml-chtml.js:1) 处读取 null 的属性“appendChild”
我是 javascript 新手。我预先感谢您分享任何错误或建议,以使代码正常工作。