Use jQuery FreezeTable to build a scrollable table

Here we’ll use jQuery FreezeTable plugin to freeze the header and add a vertical scroll bar to a lengthly table.

The end result will look like this:

Step 1: The HTML

<table id="mytable">
    <col class="column-make" />
    <col class="column-display" />
    <col class="column-country" />       

The table markup needs to adhere to the HTML 4.01 Specification for Tables. The row groups THEAD and TBODY are used to determine which sections of the table should be frozen. jquery.freezetable clones the table and removes the TBODY from the cloned copy to ‘freeze’ the header. It then removes the THEAD from the original table to make the scrollable portion of the table. jquery.freezetable also depends on COLGROUP to maintain consistent column styling between the orginal and cloned header table.

Step 2: The JavaScript

$(document).ready(function () {
        'autoHeight': false,
        'height': 160

AutoHeight Demo
Fixed height Demo
Interactive Demo on JSFIDDLE

Download FreezeTable from GitHub

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.