How do I load a javascript file dynamically?
<p>I have this code:</p>

<pre><code>    &lt;script type="text/javascript"&gt;
    function js() {
        var getJs = document.getElementById("jogo");

        if (JS == true) { //if button JS is pressed - it is correct?

            &lt; script type = "text/javascript"
            src = "file1.js" &gt;


        } else &lt; script type = "text/javascript"
        src = "file2.js" &gt;
&lt;/script&gt;
}
&lt;/script&gt;
</code></pre>

<p>it doesn't work. I gave two buttons, if the first is pressed, <code>file1.js</code> should be loaded. In case the second one is pressed, <code>file2.js</code> should be loaded.</p>

<p>How can I do that?</p>
