简体   繁体   English

动态生成内容时,jqMath不呈现公式

[英]jqMath does not render a formula when content is generated dynamically

I'm looking at HTML which is generated dynamically with JavaScript. 我正在查看使用JavaScript动态生成的HTML。 Here is how it is done 这是完成的方式

var el = $('body').find('div#my-div.main');
el.html('');
el.append($("<p>If $ax^2+bx+c=0$ with $a≠0$, then:$$x={-b±√{b^2-4ac}}/{2a}$$</p>"));

However no formula is rendered on the page. 但是,页面上没有呈现公式。 I see the exact text that is in the p tag. 我看到了p标记中的确切文本。 I did check the path to jqMath script and jqMath css and they are both correct. 我确实检查了jqMath脚本和jqMath css的路径,它们都是正确的。

Does anyone know why this is happening and how to fix it? 有谁知道为什么会这样以及如何解决?

Call parseMath function once you append the formula like this - 像这样追加公式后,调用parseMath函数-

        var el = $('body').find('div#my-div.main');
        el.html('');
        el.append("<p>If $ax^2+bx+c=0$ with $a≠0$, then:$$x={-b±√{b^2-4ac}}/{2a}$$</p>");
        jqMath.parseMath(document.body);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM