Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/371.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/assembly/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 实时显示mathjax输出_Javascript_Jquery_Mathjax - Fatal编程技术网

Javascript 实时显示mathjax输出

Javascript 实时显示mathjax输出,javascript,jquery,mathjax,Javascript,Jquery,Mathjax,如何在键入时将此mathjax示例修改为实时预览?现在它只在我按下enter键后显示结果。我想对其进行调整,使其工作原理类似于stackoverflow/math.stackexchange在键入问题时显示预览的方式 <html> <head> <title>MathJax Dynamic Math Test Page</title> <script type="text/x-mathjax-config"> MathJax.Hu

如何在键入时将此mathjax示例修改为实时预览?现在它只在我按下enter键后显示结果。我想对其进行调整,使其工作原理类似于stackoverflow/math.stackexchange在键入问题时显示预览的方式

<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>

MathJax动态数学测试页面
MathJax.Hub.Config({
tex2jax:{
inlineMath:[[“$”,“$”],[“\\(“,“\\)”]]
}
});
//
//使用闭包可以从
//全局命名空间
//
(功能(){
var QUEUE=MathJax.Hub.QUEUE;//队列的简写
var math=null;//数学输出的元素jax。
//
//在MathJax生成元素jax时获取它。
//
QUEUE.Push(函数(){
math=MathJax.Hub.getAllJax(“MathOutput”)[0];
});
//
//用于键入的onchange事件处理程序
//用户输入的数学
//
window.UpdateMath=函数(TeX){
Push([“Text”,math,“\\displaystyle{”+TeX+“}]”);
}
})();
键入一些TeX代码:

您键入:${}$

不要使用
onchange
尝试
onkeypress
onkeypup


onchange
仅在您离开该字段时触发,但其他(显然)事件会在每次按键时发生。

我怀疑您使用的是Internet Explorer,它不会像其他浏览器那样频繁或高效地触发
onchange
事件

中的版本包含更多代码以更好地处理IE。您可能需要查看那里的源代码以了解详细信息。


MathJax.Hub.Config({tex2jax:{inlineMath:[['$','$'],[“\\(“,“\\)”]),processEscapes:true});
函数f(){
var输入=document.getElementById(“输入”);
document.getElementById(“输出”).innerHTML=input.value;
Queue([“Typeset”,MathJax.Hub]);
}

是的,因为只有按下回车键或字段模糊时才会触发
onchange
。请注意:cdn.mathjax.org的使用寿命即将结束,检查迁移提示。@PeterKrautzberger在wordpress站点上显示MathJax实时预览的最佳方式是什么?该站点有输入字段,用于用数学公式编写问题/注释。对于绝对初学者,请指导“what”和“where”键入一些脚本(如果有的话)。Thanks@think123在wordpress站点上显示MathJax的实时预览的最佳方式是什么?该站点有一个输入字段,用于用数学公式编写问题/评论。对于绝对初学者,请指导“what”和“where”键入一些脚本(如果有的话)。感谢事实上并非如此。在wordpress网站上显示MathJax实时预览的最佳方式是什么?该网站上有输入字段,用于用数学公式编写问题/评论。对于绝对初学者,请指导“what”和“where”键入一些脚本(如果有的话)。谢谢