title: Confused about global variable not updating
body: <p>I have the following code:</p>
  
  <pre><code>var clickCount = 1;
  var slideCount = $('div.slide').length;
  
  $('a#next-button').click(function() {
      if(clickCount &lt; slideCount) {
          $('div.slide').animate({"left":"-=" + slideWidth}, 'slow');
          clickCount = clickCount + 1;
      }
  });
  
  $('p').text(clickCount); 
  </code></pre>
  
  <p>It has a global variable called <code>clickCount</code>.</p>
  
  <p>The <code>$('a#next-button').click(function() { …</code> updates the global variable with an increment of 1, each time the <code>&lt;a&gt;</code> element is clicked.</p>
  
  <p>So, my question is, why does: <code>$('p').text(clickCount);</code>
  not show me the updated clickCount on the page everytine the <code>&lt;a&gt;</code> tag is clicked. Instead it just shows 1 (the original assigned value).</p>