如何将输出值更改为 Mathjax 样式?

how can I change the output value into Mathjax style?

我必须使用 HTML 和 JavaScript 来设计一个具有两个输入字段 (a & b) 和一个操作按钮的网站,当单击该按钮时,下面的部分将显示a + b 的加法运算结果(c) 这是我写的

<script>
    MathJax.Hub.Config({
            tex2jax: {
            inlineMath: [ ['$','$'], ["\(","\)"] ],
            displayMath: [ ['$$','$$'], ["\[","\]"] ]
            }});

</script>

<script> 
  var asw = null;
  var a=null;
  var b=null;
  function math(){

 if(asw==null) asw=document.getElementById("answer");
  a=document.getElementById("num1");
  b=document.getElementById("num2");
  a1 = parseInt(a.value);
  b2 = parseInt(b.value);
  c = a1+b2   
  asw.innerHTML = ("$$a+b=$$"+ c);

  MathJax.Hub.Queue(["Typeset",MathJax.Hub]);
  MathJax.Hub.processSectionDelay=0;

  };
</script>

<body>
<input type="button" onclick="math()" value="action">
a=<input type="text"id="num1"><br> 
b=<input type="text"id="num2">
<div id="answer" >

</div>

但在这种情况下,如果我输入a=1,b=2,那么该部分将仅以正常方式显示加法结果3,而在Mathjax中则不显示;如果我改变 asw.innerHTML = ("$$a+b=$$"+ c);进入 asw.innerHTML = ("$$a+b=$$"+ "$$c$$") ,然后结果将在 mathjax 中显示 "a+b=c",而不是 "a+b=3",所以我想问一下如何解决这个问题?

使用

asw.innerHTML = ("$$a+b=" + c + "$$");

c 的值包含在数学中。使用

asw.innerHTML = ("$$" + a + "+" + b + "=" + c + "$$");

获取 ab 的值也插入到数学中。