-1

I am working on a fixed table header where I have a scrollbar. I am taking 2 tables one on top and other on bottom. Top table will have headers (Name, Address, Phone, Details), bottom table will have all rows with details. I have to add extra width 20px to last th to sync widths of both top table and bottom table. This might not be 20px but equal to scrollbar width. What I tried is any suggestion? My table is dynamically populated.

// Adding table width to sync with scrollbar
$(document).ready(function () {

    var thLastWidth = $('#fixedHeaderTable th:last').width()+18;
    $('#fixedHeaderTable th:last').css('width', thLastWidth + 'px');
});
Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
Kurkula
  • 6,386
  • 27
  • 127
  • 202

1 Answers1

0

try:

var thLastWidth = function(i){
    i = $('#fixedHeaderTable th:last').width()+18;
    return i;
}
13ruce1337
  • 753
  • 1
  • 6
  • 13