title: jquery variable addicion issues
body: <p>I'm having an issue with my variable adding itself to itself. </p>
  
  <p>The variable starts off as <code>0</code>, then It'll add <code>1</code> to itself and then never do it again.
  I wondered if anyone had any idea on how to fix this, as my major issue is that the variable <strong>cannot</strong> be global has more than one of these variables will be used. The table is 12x24, meaning there are alot of <code>td</code>.</p>
  
  <p>Example:</p>
  
  <blockquote>
    <p>if you click in td:nth-child(1) that will use a different variable
    compared to td:nth-child(5)</p>
  </blockquote>
  
  <p>So heres my code so far (<a href="http://jsfiddle.net/SaiyanToaster/xpmkmLj1/1/" rel="nofollow">jsFiddle</a>):</p>
  
  <p>jQuery:</p>
  
  <pre><code>$('table.masteries tr.p0 td').on('click', function(){
      i = 0
      s = $(this).find('p').text()
      current_max = parseInt(s.substr(s.length - 1))
      if (
          $(this).is($(':nth-child(1)'))
          || $(this).is($(':nth-child(2)'))
          || $(this).is($(':nth-child(3)'))
          || $(this).is($(':nth-child(4)'))
      ) {
          i = i + 1 /&lt;-- the issue
          console.log(i) /&lt;-- the issue
          $(this).closest('span').append(i); /&lt;-- the issue
      } else if (
          $(this).is($(':nth-child(5)'))
          || $(this).is($(':nth-child(6)'))
          || $(this).is($(':nth-child(7)'))
          || $(this).is($(':nth-child(8)'))
      ) {
  
      } else if (
          $(this).is($(':nth-child(9)'))
          || $(this).is($(':nth-child(10)'))
          || $(this).is($(':nth-child(11)'))
          || $(this).is($(':nth-child(12)'))
      ) {
  
      }
  });
  </code></pre>
  
  <p>Snippet of HTML:</p>
  
  <pre><code>&lt;table class="masteries" border="1"&gt;
          &lt;tr class="p0"&gt;
              &lt;td&gt;&lt;p&gt;&lt;span&gt;0&lt;/span&gt;/1&lt;/p&gt;&lt;/td&gt;
              &lt;td&gt;&lt;p&gt;&lt;span&gt;0&lt;/span&gt;/4&lt;/p&gt;&lt;/td&gt;
              &lt;td&gt;&lt;p&gt;&lt;span&gt;0&lt;/span&gt;/4&lt;/p&gt;&lt;/td&gt;
              &lt;td&gt;&lt;p&gt;&lt;span&gt;0&lt;/span&gt;/1&lt;/p&gt;&lt;/td&gt;
  
              &lt;td&gt;&lt;p&gt;&lt;span&gt;0&lt;/span&gt;/2&lt;/p&gt;&lt;/td&gt;
              &lt;td&gt;&lt;p&gt;&lt;span&gt;0&lt;/span&gt;/2&lt;/p&gt;&lt;/td&gt;
              &lt;td&gt;&lt;p&gt;&lt;span&gt;0&lt;/span&gt;/2&lt;/p&gt;&lt;/td&gt;
              &lt;td&gt;&lt;p&gt;&lt;span&gt;0&lt;/span&gt;/2&lt;/p&gt;&lt;/td&gt;
  
              &lt;td&gt;&lt;p&gt;&lt;span&gt;0&lt;/span&gt;/1&lt;/p&gt;&lt;/td&gt;
              &lt;td&gt;&lt;p&gt;&lt;span&gt;0&lt;/span&gt;/3&lt;/p&gt;&lt;/td&gt;
              &lt;td&gt;&lt;p&gt;&lt;span&gt;0&lt;/span&gt;/3&lt;/p&gt;&lt;/td&gt;
              &lt;td&gt;&lt;p&gt;&lt;span&gt;0&lt;/span&gt;/1&lt;/p&gt;&lt;/td&gt;
          &lt;/tr&gt;
  &lt;/table&gt;
  </code></pre>