jQuery syntax error? Css and Animate in 'if' and 'else' statements 
<p>Edit - Ive changed my code:</p>

<p>This works fine:</p>

<pre><code>$(".image-div").click(function () {
        if ($(this).css('z-index') == 1) 
            $(this).css('z-index','2');
        else 
            $(this).css('z-index','1');
});
</code></pre>

<p>And this also works:</p>

<pre><code>    $(".image-div").click(function () {
        if ($(this).css('z-index') == 1) 
            $(this).animate({
                width: '500px'
            }, 5000, function() {
                // Animation complete.
            });
        else 
            $(this).animate({
                width: '250px'
            }, 5000, function() {
                // Animation complete.
            });
    });
</code></pre>

<p>But this doesn't do anything: </p>

<pre><code>    $(".image-div").click(function () {
        if ($(this).css('z-index') == 1) 
            $(this).css('z-index','2');
            $(this).animate({
                width: '500px'
            }, 5000, function() {
                // Animation complete.
            });
        else 
            $(this).css('z-index','1');
            $(this).animate({
                width: '250px'
            }, 5000, function() {
                // Animation complete.
            });
    });
</code></pre>

<p>Thanks</p>
