title: JQuery - check checkboxes in table
body: <p>I'm populating rows in a table from an array. Each row has a checkbox, which I want to be checked depending on certain conditions. </p>
  
  <p>So after populating each row, I'm trying to check the checkbox, but using this doesn't seem to check it:</p>
  
  <pre><code>if(invoices[i].paid == 'yes'){
      $('.filterPaid').prop('checked', false);
  }else{
      $('.filterPaid').prop('checked', true);
  }
  </code></pre>
  
  <p>This is the code:</p>
  
  <pre><code>var invoices = {% raw json_encode(invoices) %};
  //console.log(invoices);
  var addRow = '';
  for(var i = 0; i &lt; invoices.length; i++){
      //alert(invoices[i].invoiceDueYear);
  
      var date = new Date(invoices[i].invoiceDueYear,invoices[i].invoiceDueMonth,invoices[i].invoiceDueDay);
      var d = date.getDate();
      var month = new Array();
      month[0] = "Jan";
      month[1] = "Feb";
      month[2] = "Mar";
      month[3] = "Apr";
      month[4] = "May";
      month[5] = "Jun";
      month[6] = "Jul";
      month[7] = "Aug";
      month[8] = "Sep";
      month[9] = "Oct";
      month[10] = "Nov";
      month[11] = "Dec";
      var m = month[date.getMonth()]; 
  
      var y = date.getFullYear();
  
      var inv = pad(invoices[i].invoiceNo,9,3);
  
      if(invoices[i].currency === 'GB'){
          var currency = '&amp;#163;';
      }else if(invoices[i].currency === 'US'){
          var currency = '&amp;#36;';
      }else{
          var currency = '&amp;#8364;';
      }
  
      addRow += '&lt;tr&gt;&lt;td&gt;&lt;input type="checkbox" class="filterPaid" id="invPaid'+i+'" value="outstanding" name="filterTasks[]"&gt;&lt;/td&gt;&lt;td class="invoiceView" value="'+invoices[i].uid+'"&gt;&lt;a href="#"&gt;' + inv + '&lt;/a&gt;&lt;/td&gt;&lt;td&gt;' + invoices[i].creditorName + '&lt;/td&gt;&lt;td&gt;' + currency + '' + invoices[i].balance + '&lt;/td&gt;&lt;td&gt;' + d + ' '+ m +' '+y+'&lt;/td&gt;&lt;/tr&gt;';
  
      if(invoices[i].paid == 'yes'){
          $('.filterPaid').prop('checked', false);
      }else{
          $('.filterPaid').prop('checked', true);
      }
  }
  $('#invoiceTable tr').first().after(addRow);
  </code></pre>
  
  <p>Why wouldn't it check the checkboxes in this instance?</p>