title: getElementsByClassName not working
body: <p>I coded a php page that displays information from a mysql database neatly into tables. I would like to hide empty table rows with an onLoad event handler.</p>
  
  <p>Here is a sample table with code that hides a <code>&lt;td&gt;</code> when it has no content. but i can only get it to work with different IDs:</p>
  
  <pre><code>        &lt;script type="text/javascript"&gt;
          function hideTd(id){
              if(document.getElementById(id).textContent == ''){
                document.getElementById(id).style.display = 'none';
              }
            }
          &lt;/script&gt;
          &lt;/head&gt;
          &lt;body onload="hideTd('1');hideTd('2');hideTd('3');"&gt;
          &lt;table border="1"&gt;
            &lt;tr&gt;
              &lt;td id="1"&gt;not empty&lt;/td&gt;
            &lt;/tr&gt;
            &lt;tr&gt;
              &lt;td id="2"&gt;&lt;/td&gt;
            &lt;/tr&gt;
            &lt;tr&gt;
              &lt;td id="3"&gt;&lt;/td&gt;
            &lt;/tr&gt;
          &lt;/table&gt;
      &lt;/body&gt;
  </code></pre>
  
  <p>what i want to do is use a class for the <code>&lt;td&gt;</code>s to achieve the same thing while only referencing the class once, and not referencing every single id that I want to remove, which will not even work for my dynamic content. I tried using this code:</p>
  
  <pre><code>    &lt;script type="text/javascript"&gt;
      function hideTd(){
          if(document.getElementsByClassName().textContent == ''){
            document.getElementsByClassName().style.display = 'none';
          }
        }
      &lt;/script&gt;
      &lt;/head&gt;
      &lt;body onload="hideTd('1');"&gt;
      &lt;table border="1"&gt;
        &lt;tr&gt;
          &lt;td class="1"&gt;not empty&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;td class="1"&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;td class="1"&gt;&lt;/td&gt;
        &lt;/tr&gt;
      &lt;/table&gt;
  &lt;/body&gt;
  </code></pre>
  
  <p>but it does not work. its supposed to hide the empty <code>&lt;td&gt;</code>s that have the specified class. how do i hide empty <code>&lt;td&gt;</code>s using classes, not IDs?</p>