Search code examples
asp.net-mvc-3mathjax

How to use MathJax in a form?


I have a textbox in a form and I want to use MathJax.I have downloaded it, but don't know how to use it. I am using ASP-MVC3. Thanks for your helps.


Solution

  • I found the issue.Its just needed to load js files from mathjax.org and add these lines to the head tag.

    <script type="text/javascript">
        $(document).ready(function () {
            MathJax.Hub.Config({ TeX: { equationNumbers: { autoNumber: "all" } } });
        });
    </script>
    <script src="~/Scripts/MathJax.js?config=Tex-AMS_HTML"></script>
    

    And now its just needed to add the characters $$ and \\ to the text in the following form and append it to something like a div.

    jQuery("#radikal").on('click', function () {
        var x="$$\\sqrt[3]{8}$$";
        $("#formul").append(x);
    });
    
    <input type="button" id="radikal"/>
    <div id="formul"></div>
    

    And now we will have a radical in div#radikal. Thats all.