0

I’ve to create a custom text field which is support some of the mathematical expression also. So I thought of using JQMath.

I’ve to pass a expression with html input field using javascript. It’ll be added dynamically. So I put the expression in a string which is changeable anytime. But if I use the string, it didn’t give the positive output. I googled a lot about this, but I cant get it. Please help me on this.

Below is my code.

var string = "$x={-b±√{b^2-4ac}}/{2a\html'<input size=1 >'}$"

var di = document.createElement("div");    

di.innerHTML = string//+textStr;    

document.body.appendChild(di);    

M.parseMath(di)    
VividD
  • 10,456
  • 6
  • 64
  • 111
flashyhawk
  • 11
  • 1
  • I suspect it's because the library doesn't understand `±` or `√`. Don't get me wrong, Unicode is a nice idea, but it's pretty hard to type. – John Dvorak May 28 '13 at 06:18

1 Answers1

1

The \ in the javascript quoted string source needs to be doubled \\ to produce a \ in the actual string. Alternatively, jqMath also supports ` backquote for its macros, to avoid this annoyance.

Jan, the library does support mathematical Unicode characters, and the main jqMath page at http://mathscribe.com/author/jqmath.html has a table to help you find and type them.

Dave Barton
  • 1,429
  • 13
  • 12