title: How to iterate through td in a tbody?
body: <pre><code>&lt;table&gt; 
      &lt;tbody id="SAMPLETBODY"&gt;
          &lt;tr&gt;
              &lt;td&gt;TEST1&lt;/td&gt;
              &lt;td&gt;TEST2&lt;/td&gt;
              &lt;td&gt;TEST3&lt;/td&gt;
              &lt;td&gt;TEST4&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
  &lt;/table&gt;
  </code></pre>
  
  <p>I have the code above, I want to iterate through the td's, since iterating through tbodies in a table is like this:</p>
  
  <pre><code>var table1 = document.getElementById('firstTable');
  for(int i = 0; i &lt; table1.tBodies.length; i++) {
      /*DO SOMETHING HERE*/
  }
  </code></pre>
  
  <p>How can I do it in td inside tbodies?</p>
  
  <p>EDIT:</p>
  
  <p>I have multiple tbodies in the table, I have already tried some codes that is similar (It iterated through all tbodies) and posted here before I asked the question.</p>
  
  <p>EDIT AGAIN:</p>
  
  <p>final code:</p>
  
  <pre><code>function sampleFunc() {
      var x = "";
      var tds = document.querySelectorAll('#SAMPLETBODY td'), i;
      for(i = 0; i &lt; tds.length; ++i) {
          x = x + tds[i].innerHTML;
      }
      return x;
  }
  </code></pre>
  
  <p>thanks to:rink.attendant.6</p>