title: jQuery chaining if-statement
body: <p>I am making a table display optimization of my website when the windows width gets below 500px, in which I want the tables to only have 2 columns; Title, Teaser.</p>
  
  <p>As of now I am chaining like this:</p>
  
  <pre><code>var $rows = $(".zn-listviewtable tr");
  if ($rows.children('td').length &gt; 3) {
      $rows.find("td:gt(2)").remove().end().find("th:gt(2)").remove().end().find("td:lt(1)").remove().end().find("th:lt(1)").remove();
  }
  </code></pre>
  
  <p>As you can see I have an if-statement checking if there's more than 3 columns (or <code>td</code>'s) and if so, then remove all that is <code>&gt;</code> 2 and <code>&lt;</code> 1.</p>
  
  <p>The only field which is <code>&lt;</code> 1 is a checkbox field in each row. Not all my tables has this field, so I only want to apply the <code>remove()</code> on those which does have it.</p>
  
  <p>Is there a way to check of this during the chaining rather than splitting it up and then start all over in a seperate one, avoiding it ending up like this:</p>
  
  <pre><code>var $rows = $(".zn-listviewtable tr");
  if ($rows.children('td').length &gt; 3) {
      $rows.find("td:gt(2)").remove().end().find("th:gt(2)").remove();
  }
  if ($rows.children('td').find('input:checkbox').length &gt; 0) {
      $rows.find("td:lt(1)").remove().end().find("th:lt(1)").remove();
  }
  </code></pre>