0

Need to autogenerate a jqMath formula with input tag in it. I took some of the code from the example provided by jqMath. Here is the code:

var $el = $('body').find('div#mydiv.main');
$el.html('');
$el.append(
   $("<p>\"If $$y = ax^\html'&lt;input type=\"text\" size=1>'+bx+c=0$$ with $a≠0$, then:$$x={-b±√{b^2-4ac}}/{2a}$$\"</p>")            
);

Per jqMath instructions, I do have the following line in my HTML

<script>M.MathPlayer = false; M.trustHtml = true;</script>

However what I get looks like this:

jqMath image output

I'm not quite sure what I'm doing wrong.

flashburn
  • 4,180
  • 7
  • 54
  • 109
  • Have you tried replacing `<` with `<` since `<` is the **HTML entity** for **<** – NewToJS Oct 26 '17 at 23:01
  • @NewToJS Yes I did try doing it, but it didn't work. [Here is what I'm getting](https://imagebin.ca/v/3fACmgW34vJi) – flashburn Oct 26 '17 at 23:11
  • If that doesn't work then maybe try this `html'<'` I have looked just looked online at `jqmath`, it isn't something I have every used before but when I use `html'<` I get this message **Missing closing '** so a single quote might be needed. [**CodePen Demo**](https://codepen.io/monkeyraptor/details/jAQpkW) This is what I used to find that missing closing error so it might be of some use to you? – NewToJS Oct 26 '17 at 23:12
  • @NewToJS No that doesn't work. The format is \html 'plain html text'. But I did try your suggestion. – flashburn Oct 26 '17 at 23:15
  • Oh okay, was a shot in the dark as I haven't used it before, might you need to use `html'<'` for the paragraph tags too? This is my last guess. It might also be helpful if you can show your expected output. I hope you find a solution. – NewToJS Oct 26 '17 at 23:22
  • @NewToJS what should be the value of your input? `'+bx+c=0'` ? here https://codepen.io/headmax/pen/OOLjMR?editors=1011 –  Oct 26 '17 at 23:51
  • @NewToJS I figured it out. Here is what I need to do `$el.append( "

    $$y = ax^\\html'<input type=\"text\" size=1>'+bx+c=0$$ with $a≠0$, then:$$x={-b±√{b^2-4ac}}/{2a}$$

    ") );` Don't append as $("

    "), but append as

    and use `\\html` instead of `\html`
    – flashburn Oct 26 '17 at 23:55
  • @flashburn Could you mind updating your question to show you have solved the problem and include what you have changed to fix the issue? This might help future visitors who experience the same problem and are looking for help. I'm sure it would be appreciated if you did. Thank you very much. – NewToJS Oct 27 '17 at 00:07

0 Answers0