我有一个问题,我想使用“文本框”添加数字来添加我的公式数学,但它不会呈现它
<p style="text-align:center; font-size:40px;">
`int ax^n dx `
</p>
Input nilai a : <input type="text" id="a" value="10">
Input nilai n : <input type="text" id="n" value="5">
<button onclick="coba()">OK</button>
<div id="tampil"></div>
<script>
function coba(){
var a= document.getElementById("a").value;
var n= document.getElementById("n").value;
var e= "`int"+ a +"x^"+ n + "dx`"
var f= a+n;
document.getElementById("tampil").innerHTML= e;
}
</script>
最佳答案
您需要在设置innerHTML
后告诉MathJax 新的数学已经添加到页面中。通过添加
MathJax.Hub.Queue(["Typeset",MathJax.Hub,"tampil"]);
设置innerHTML
之后。
参见 documentation了解更多详情。
关于Javascript 和 mathjax ascii,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41521277/