I have a table with much rows and columns. The table header needs to be fixed on the browser window when scrolling vertical. I have done that by adding a style position: fixed;
to the table head when it reaches the top of the browser window.
But when I scroll horizontally the table header is not scrolling in the way as I applied the fixed position.
How can I make the table header scroll horizontally (also).
Javascript:
$(window).scroll(function () {
var spec_lot_dash_sticky = $('.spec_dash_thead'),
spec_lot_dash_scroll = $(window).scrollTop();
if (spec_lot_dash_scroll >= ($("#table_id").offset().top)) {
spec_lot_dash_sticky.addClass('fixed')
$(".fixed").css("top", spec_lot_dash_thead_scroll_top)
} else {
spec_lot_dash_sticky.removeClass('fixed');
}
});
jsfiddle link First scroll the vertical bar and then scroll horizontall scroll bar. The table header is not scrolling.