Currently, I am implementing this JQuery script for my table.
$(document).ready(function () {
var tableBottom = $(window).height() - $('#compare-table').height();
$(window).scroll(function (event) {
var y = $(this).scrollTop();
var tableTop = $('#compare-table').offset().top;
if (y >= tableTop && y <= tableBottom) {
$('#compare-table-controller').addClass('fixed');
$('#compare-table-controller').css('margin-top', '-' + tableTop + 'px');
} else {
$('#compare-table-controller').removeClass('fixed');
$('#compare-table-controller').css('margin-top', '0px');
}
});
var compareTableHeight = $('#compare-table > table').height() + 1;
var compareTableTotalColumn = $('#compare-table > table').width() / 195;
$('#compare-table').css('height', compareTableHeight);
alert($('#compare-table > table').width());
});
Interestingly, I am encountering discrepancies in the values retrieved by the alert() function when using Chrome version 28.0.1500.71 and Firefox version 22.0. The expected value should be 1170px.
Consequently, all 6 columns are visible on Firefox, whereas only 4 columns should be displayed, with the other 2 hidden.
Here are the CSS styles applied to the displayed div elements.
#compare-table-h {
width: 780px;
overflow: hidden;
position:fixed;
height: 213px;
z-index: 999;
}
#compare-table {
width: 780px;
overflow: hidden;
position:relative;
margin-top: 213px;
}
Additionally, the tables inside the div elements are structured as follows:
<table id="compare-table-head" class="table font-size-12 compare-table table-striped" style="position:absolute; border-bottom:1px solid #ddd; width: 1170px;">
While the first table functions correctly, the second table poses issues.