title: Copying Cell Widths to a Fixed-Position Clone Table
body: <p>By generalizing the code in <a href="https://stackoverflow.com/questions/4709390/table-header-to-stay-fixed-at-the-top-when-user-scrolls-it-out-of-view-with-jquer/4709775#4709775">this SO answer</a>, I've created a small jQuery plug-in which makes it easy to set up a scrolling header on any table - that is, when you scroll down such that the table header would normally be outside of the viewable window, a clone of the header becomes fixed to the top of the window so that you can see which columns are which.  That's all working fine, but the problem I'm having is that I can't get the column widths to match up perfectly between the clone table and the original table.</p>
  
  <p>I've created a jsFiddle which demonstrates the problem <a href="http://jsfiddle.net/YVMKu/4/" rel="nofollow noreferrer">here</a>.  The gist of it is that I'm using the following loop to copy cell widths from the parent table to the clone table:</p>
  
  <pre><code>$("#tbl1").find('tr').first().children().each(function(i, e)
  {
      $($("#tbl1_clone").find('tr').children()[i]).width($(e).width());
  });
  </code></pre>
  
  <p>This is necessary because the clone table only consists of the parent table's header; it has none of the content, therefore its column widths would be different than the parent table's without this step.  However, this loop doesn't quite work properly.  The cell widths in the cloned table are always off by a few pixels.  This happens in both IE8 and Chrome (and presumably others, though I haven't tested them.)</p>
  
  <p>I'm at a complete loss as to how to correct this problem.  Please check out <a href="http://jsfiddle.net/YVMKu/4/" rel="nofollow noreferrer">the jsFiddle</a>, as it explains the problem much better than I have.</p>
  
  <p>It's perhaps worth noting that the same code seems to work when the clone table's position is <em>not</em> fixed.  However, that's of no use to me, since I need it to be fixed.</p>