title: Add class to current tr
body: <p>I'm dynamically populating a table. If a certain condition applies, I want to add a class to the current <code>tr</code>:</p>
  
  <pre><code>number = 3;
  
  for (i = 0; i &lt; 5; i++) {
    var row = "";
    row += "&lt;tr&gt;&lt;td&gt;Test" + i + "&lt;/td&gt;&lt;/tr&gt;"
  
    $('#mytable').find('tbody:last').append(row);
  
    if (i == number) {
      $('#mytable').find('tbody:last').addClass("red");
    }
  }
  </code></pre>
  
  <p>Unfortunately, the class is being added to all <code>tr</code>s, not only the one of them.</p>
  
  <p><a href="https://jsfiddle.net/Lan0fv36/" rel="nofollow">Here is a fiddle</a>.</p>