Unexpected order in script execution
<p>Why is it running the second script and how can I make it work like a toggle control?</p>

<pre><code>&lt;script&gt;
    var el = 2;

    $(document).ready(function(){
        $(".rightDiv").click(function(){
            if (el == 2) {
                $(this).animate({left:'150px'});
                el = 1;
            }
        });
    });
&lt;/script&gt;

&lt;script&gt;

    $(document).ready(function(){
        $(".rightDiv").click(function(){
            if (el==1) {
                $(this).animate({left:'50px'});
                el = 2;
            }
        });
    });
&lt;/script&gt;
</code></pre>
