title: Table header to stay fixed at the top when user scrolls it out of view with jQuery
body: <p>I am trying to design an HTML table where the header will stay at the top of the page when AND ONLY when the user scrolls it out of view.  For example, the table may be 500 pixels down from the page, how do I make it so that if the user scrolls the header out of view (browser detects its no longer in the windows view somehow), it will stay put at the top?  Anyone can give me a Javascript solution to this?</p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;table&gt;
    &lt;thead&gt;
      &lt;tr&gt;
        &lt;th&gt;Col1&lt;/th&gt;
        &lt;th&gt;Col2&lt;/th&gt;
        &lt;th&gt;Col3&lt;/th&gt;
      &lt;/tr&gt;
    &lt;/thead&gt;
    &lt;tbody&gt;
      &lt;tr&gt;
        &lt;td&gt;info&lt;/td&gt;
        &lt;td&gt;info&lt;/td&gt;
        &lt;td&gt;info&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;info&lt;/td&gt;
        &lt;td&gt;info&lt;/td&gt;
        &lt;td&gt;info&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;info&lt;/td&gt;
        &lt;td&gt;info&lt;/td&gt;
        &lt;td&gt;info&lt;/td&gt;
      &lt;/tr&gt;
    &lt;/tbody&gt;
  &lt;/table&gt;</code></pre>
  </div>
  </div>
  </p>
  <p>So in the above example, I want the <code>&lt;thead&gt;</code> to scroll with the page if it goes out of view.</p>
  <p>IMPORTANT: I am <strong>NOT</strong> looking for a solution where the <code>&lt;tbody&gt;</code> will have a scrollbar (overflow:auto).</p>