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
7 Dec 14, 11:23PM
(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, 3: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, 4: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.