I want to do this as easily as possible with out any additional libraries.
In my very long table I want to add a scrollbar to the
These solutions often have issues with the header columns aligning with the body columns, and may not work properly when resizing. I know you didn't want to use an additional library, but if you happen to be using jQuery, this one is really small. It supports fixed header, footer, column spanning (colspan), horizontal scrolling, resizing, and an optional number of rows to display before scrolling starts. jQuery.scrollTableBody (GitHub) As long as you have a table with proper tag so
,
, and (optional)
, all you need to do is this:
$('table').scrollTableBody();