如何在輸入時修改此mathjax示例以進行實時預覽?現在它只在按下輸入後顯示結果。我想調整它,使其工作方式類似於輸入問題時,stackoverflow/math.stackexchange如何顯示預覽。實時顯示mathjax輸出
<html>
<head>
<title>MathJax Dynamic Math Test Page</title>
<script type="text/x-mathjax-config">
MathJax.Hub.Config({
tex2jax: {
inlineMath: [["$","$"],["\\(","\\)"]]
}
});
</script>
<script type="text/javascript"
src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML-full">
</script>
</head>
<body>
<script>
//
// Use a closure to hide the local variables from the
// global namespace
//
(function() {
var QUEUE = MathJax.Hub.queue; // shorthand for the queue
var math = null; // the element jax for the math output.
//
// Get the element jax when MathJax has produced it.
//
QUEUE.Push(function() {
math = MathJax.Hub.getAllJax("MathOutput")[0];
});
//
// The onchange event handler that typesets the
// math entered by the user
//
window.UpdateMath = function (TeX) {
QUEUE.Push(["Text",math,"\\displaystyle{"+TeX+"}"]);
}
})();
</script>
Type some TeX code:
<input id="MathInput" size="50" onchange="UpdateMath(this.value)" />
<p>
<div id="MathOutput">
You typed: ${}$
</div>
</body>
</html>
是的,因爲'onchange'只有在按下回車鍵或當場模糊時纔會觸發。 – think123
未來的注意事項:cdn.mathjax.org即將到期,請查看https://www.mathjax.org/cdn-shutting-down/獲取遷移提示。 –
@PeterKrautzberger什麼是最好的方式來顯示MathJax的實時預覽在一個wordpress網站有輸入字段用數學公式編寫問題/評論。對於絕對的初學者,請指導「what」和「where」鍵入一些腳本,如果有的話。謝謝 – user12345