title: Iterate through selective cells in a table row JavaScript / jQuery
body: <p>I have been having this issue which I haven't quite been able to solve through other given solutions. </p>
  
  <p>I am trying to get certain values of each row in a table. 
  The issue is coming from a fairly unformatted table, so I have to get cell values based on their index or location. </p>
  
  <p>This is the table in question:</p>
  
  <pre><code>&lt;table width="100%"&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;td&gt;Item Description&lt;/td&gt;
              &lt;td&gt;Colour&lt;/td&gt;
              &lt;td&gt;Size&lt;/td&gt;
              &lt;td class="text-right"&gt;Price&lt;/td&gt;
              &lt;td class="text-right"&gt;Qty&lt;/td&gt;
              &lt;td class="text-right"&gt;Total&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr id="row_24551"&gt;
              &lt;td width="40%"&gt;Item 1&lt;/td&gt;
              &lt;td&gt;Ivory&lt;/td&gt;
              &lt;td&gt;10&lt;/td&gt;
              &lt;td class="text-right"&gt;$ 19.00&lt;/td&gt;
              &lt;td class="text-right"&gt;1&lt;/td&gt;
              &lt;td class="text-right"&gt;$ 19.00&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr id="row_24550"&gt;
              &lt;td width="40%"&gt;Item 2&lt;/td&gt;
              &lt;td&gt;Grey Marle&lt;/td&gt;
              &lt;td&gt;10&lt;/td&gt;
              &lt;td class="text-right"&gt;$ 18.95&lt;/td&gt;
              &lt;td class="text-right"&gt;1&lt;/td&gt;
              &lt;td class="text-right"&gt;$ 18.95&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
  &lt;/table&gt;
  </code></pre>
  
  <p>I have been getting the row values with</p>
  
  <p><code>var table = $('tr[id^="row"]')</code>
  As the information needed is in the rows with an ID. </p>
  
  <p>Can output each cells contents with </p>
  
  <pre><code>var table = $('tr[id^="row"]');
  table.each(function(){
      console.log('row');
      $.each(this.cells, function(){
          console.log($(this).text());
      });
  });
  </code></pre>
  
  <p>Where I'm getting stuck is that I only want cells [0,2,4,5] and I'm not sure how to be selective through the .each function. </p>
  
  <p>For loops make a bit more sense to me when being selective but I haven't been able to get an iteration of cells via the rows:</p>
  
  <pre><code>var table = $('tr[id^="row"]');
  for(i = 0; i &lt; table.length; i++) { 
      console.log("row");
  }
  </code></pre>
  
  <p>Also tried this </p>
  
  <pre><code>var table = $('tr[id^="row"]');
  for(var i = 0, row; row = table[i]; i++) { 
      console.log("row");
      for (var j = 0, col; col = row[j]; j++) {
          console.log("cell");
      }  
  }
  </code></pre>
  
  <p>But the cells values don't seem to come through. </p>
  
  <p>Ultimately looking to push each of the cell values needed ( [0,2,4,5] ) into a product array which will map {name, size, quantity, price}. But help with the cells would be much appreciated!</p>