Search code examples
javascriptjqueryhtmllatexmathjax

LaTeX formulas after load html


i want to load the script of Mathjaxafter using

( 'div#someone' ).load( "http source" )

Actually, it works perfectly when the page is fully loaded with it in the header.

<script class="mathlab" type="text/x-mathjax-config">MathJax.Hub.Config({tex2jax: {inlineMath: [["$","$"], ["\\(","\\)"]]}});</script>
<script class="mathlab" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>

Anyone know how to refresh the script after load ? Or maybe another script ?

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script type="text/x-mathjax-config">MathJax.Hub.Config({tex2jax: {inlineMath: [['$','$'], ['\\(','\\)']]}});</script>
<script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>



<script type="text/javascript">
    $("button").click(function() {
         $("div").text( "Hello ! What is $x$ in the formula : $$x+3=7$$" );
    });
</script>
Hello ! What is $x$ in the formula : $$x+3=7$$
<div> <button>Load something</button> </div>


Solution

  • Just add

    $( "div#someone" ).load( "http source", function () {
        MathJax.Hub.Queue(["Typeset", MathJax.Hub, "div#someone"]);
    });