I have forgotten
my Password

Or login with:

  • Facebookhttp://facebook.com/
  • Googlehttps://www.google.com/accounts/o8/id
  • Yahoohttps://me.yahoo.com
Index » Products » LaTeX Equation Editor »

How to add a fraction through javascript?

kuslanskyg\′s Photo
8 Dec 14, 5:23AM
(2 replies)
How to add a fraction through javascript?
I am making a custom explanation of how to solve some math problems, and it requires manually adding latex through javascript. For example: HTML: <div id='printContainer'></div>

JS:
var x = 5;
 var y = 4; 
document.getElementById('parseContainer').innerHTML = '\frac{' + x + '+_2' +y + '_2}{2}';
The result will look like this: http://i.imgur.com/nvq5yma.png Is it possible to directly add latex through js? Thanks.
kuslanskyg\′s Photo
8 Dec 14, 9:33PM
Thank you for responding very quickly to my question. What do you mean by escaping my quotes? I understand what that means, but I don't understand how it applies here. Can you show me an example? Sorry.
CodeCogs\′s Photo
24 May 15, 9:50AM
I suspect you need to escape your '\' in \frac. i.e.
document.getElementById('parseContainer').innerHTML = '\\frac{' + x + '+_2' +y + '_2}{2}'
Currently you need to be logged in to leave a message.