title: jQuery delete table column
body: <p>I have a table and cannot change markup:</p>
  
  <pre class="lang-html prettyprint-override"><code>&lt;table&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th&gt;
                  blablabla
              &lt;/th&gt;
              &lt;th&gt;
                  blablabla
              &lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;
                  efgd
              &lt;/td&gt;
              &lt;td&gt;
                  efghdh
              &lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
  &lt;/table&gt;
  </code></pre>
  
  <p>Here is my function, which should delete a column. It is called on cell click:</p>
  
  <pre><code>function (menuItem, menu) {
      var colnum = $(this).prevAll("td").length;
  
      $(this).closest('table').find('thead tr th:eq('+colnum+')').remove();
      $(this).closest("table").find('tbody tr td:eq('+colnum+')').remove();    
      return;
  }
  </code></pre>
  
  <p>But it deletes something else, not the column I wanted to delete. Where am I wrong?</p>