jQuery won't let me do if blocks?
<p>I am trying to do a fade effect, that fades out a div and substitutes it for another. For that I have created a lastDiv var which sets the number of the last div clicked. </p>

<p>But when I try to set an if js says there is an error. I am pretty sure that I am using the correct syntax. (I am a beginner) </p>

<p>Thanks </p>

<p></p>

<pre><code>var lastDiv = 1;

$("#item1").click(function () {
    if(lastDiv == 2) {  $("#div2").fadeOut(0500, function() { $("#div1").fadeIn(500, function () {lastDiv = 1;});   });  }); }
    else if (lastDiv == 3) {  $("#div3").fadeOut(0500, function() { $("#div1").fadeIn(500, function () {lastDiv = 1;}); });  }); }


$("#item2").click(function () {
    if(lastDiv == 1){   $("#div1").fadeOut(0500, function() { $("#div2").fadeIn(0500, function () {lastDiv = 2;}) });  }); }
    else if(lastDiv == 3){  $("#div3").fadeOut(0500, function() { $("#div2").fadeIn(0500, function () {lastDiv = 2;}) });  }); }


$("#item3").click(function () {
    if(lastDiv == 1) { $("#div1").fadeOut(0500, function() { $("#div3").fadeIn(0500, function () { lastDiv = 3 })  }); }
    else if(lastDiv == 2) { $("#div2").fadeOut(0500, function() { $("#div3").fadeIn(0500, function () { lastDiv = 3 })  }); } }); 

&lt;/script&gt;
</code></pre>
