title: How do I detect if a table exists (which doesn't have a class or ID)
body: <p>I’m having a problem trying to detect if a table exists using jQuery.  The table has no class or ID.</p>
  
  <p>What I’m trying to achieve is to not have the following code fire unless a table exists:</p>
  
  <pre><code>function tableAltRows()
      {
          $("#content table tr:even").each(function(){
              $(this).addClass("alt");
          });
      }
  $(tableAltRows);
  </code></pre>
  
  <p>So I changed the last line to:</p>
  
  <pre><code>if ($('table').length &gt; 0) {
      $(tableAltRows);
  }
  </code></pre>
  
  <p>But the line checking the table length never returns anything other than 0.  As a test, if I change it to == 0 it calls the tableAltRows function.  I’m not that familiar with jQuery, so I assume I’m missing something obvious?</p>