是否有一个脚本在java脚本中显示数学符号?

时间:2017-10-11 08:22:48

标签: javascript math

enter image description here我想在我的表单中显示数学符号,是否有脚本这样做?

//一些代码

喜欢这个图片

[数学符号] [2] enter image description here

1 个答案:

答案 0 :(得分:2)

您的符号仅限于纯HTML,有些是:



<p>I will display &sum;</p>
<p>I will display &minus;</p>
<p>I will display &times;</p>
<p>I will display &radic;</p>
<p>I will display &int;</p>

<a href="https://www.w3schools.com/charsets/ref_utf_math.asp">SOURCE</a>
&#13;
&#13;
&#13;

如果您认真,请考虑使用此库(它有启动文档):

https://www.mathjax.org/

文档位于:

http://docs.mathjax.org/en/latest/start.html

你可以这样做(使用mathjax):

<script type="text/javascript" async
  src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.2/MathJax.js?config=TeX-MML-AM_CHTML">
</script>

然后输入如下的数学字符串:

When $a \ne 0$, there are two solutions to \(ax^2 + bx + c = 0\) and they are
$$x = {-b \pm \sqrt{b^2-4ac} \over 2a}.$$

他们的一个例子是:

&#13;
&#13;
<script type="text/javascript" async
  src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.2/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<script type="text/x-mathjax-config">
  MathJax.Hub.Config({tex2jax: {inlineMath: [['$','$'], ['\\(','\\)']]}});
</script>
<div>
When $a \ne 0$, there are two solutions to \(ax^2 + bx + c = 0\) and they are
$$x = {-b \pm \sqrt{b^2-4ac} \over 2a}.$$
</div>
&#13;
&#13;
&#13;

(对不起,我看不到你发布的图片,它不会加载)

无论如何,希望这有帮助!