您好,欢迎访问一九零五行业门户网

基于jquery的固定表头和列头的代码_jquery

复制代码 代码如下:
);
}
$('
'
+ '
'
+ '
'
+ '
').appendto(# + tableid + _tablelayout);
var oldtable = $(# + tableid);
var tablefixclone = oldtable.clone(true);
tablefixclone.attr(id, tableid + _tablefixclone);
$(# + tableid + _tablefix).append(tablefixclone);
var tableheadclone = oldtable.clone(true);
tableheadclone.attr(id, tableid + _tableheadclone);
$(# + tableid + _tablehead).append(tableheadclone);
var tablecolumnclone = oldtable.clone(true);
tablecolumnclone.attr(id, tableid + _tablecolumnclone);
$(# + tableid + _tablecolumn).append(tablecolumnclone);
$(# + tableid + _tabledata).append(oldtable);
$(# + tableid + _tablelayout table).each(function () {
$(this).css(margin, 0);
});
var headheight = $(# + tableid + _tablehead thead).height();
headheight += 2;
$(# + tableid + _tablehead).css(height, headheight);
$(# + tableid + _tablefix).css(height, headheight);
var columnswidth = 0;
var columnsnumber = 0;
$(# + tableid + _tablecolumn tr:last td:lt( + fixcolumnnumber + )).each(function () {
columnswidth += $(this).outerwidth(true);
columnsnumber++;
});
columnswidth += 2;
if ($.browser.msie) {
switch ($.browser.version) {
case 7.0:
if (columnsnumber >= 3) columnswidth--;
break;
case 8.0:
if (columnsnumber >= 2) columnswidth--;
break;
}
}
$(# + tableid + _tablecolumn).css(width, columnswidth);
$(# + tableid + _tablefix).css(width, columnswidth);
$(# + tableid + _tabledata).scroll(function () {
$(# + tableid + _tablehead).scrollleft($(# + tableid + _tabledata).scrollleft());
$(# + tableid + _tablecolumn).scrolltop($(# + tableid + _tabledata).scrolltop());
});
$(# + tableid + _tablefix).css({ overflow: hidden, position: relative, z-index: 50, background-color: silver });
$(# + tableid + _tablehead).css({ overflow: hidden, width: width - 17, position: relative, z-index: 45, background-color: silver });
$(# + tableid + _tablecolumn).css({ overflow: hidden, height: height - 17, position: relative, z-index: 40, background-color: silver });
$(# + tableid + _tabledata).css({ overflow: scroll, width: width, height: height, position: relative, z-index: 35 });
if ($(# + tableid + _tablehead).width() > $(# + tableid + _tablefix table).width()) {
$(# + tableid + _tablehead).css(width, $(# + tableid + _tablefix table).width());
$(# + tableid + _tabledata).css(width, $(# + tableid + _tablefix table).width() + 17);
}
if ($(# + tableid + _tablecolumn).height() > $(# + tableid + _tablecolumn table).height()) {
$(# + tableid + _tablecolumn).css(height, $(# + tableid + _tablecolumn table).height());
$(# + tableid + _tabledata).css(height, $(# + tableid + _tablecolumn table).height() + 17);
}
$(# + tableid + _tablefix).offset($(# + tableid + _tablelayout).offset());
$(# + tableid + _tablehead).offset($(# + tableid + _tablelayout).offset());
$(# + tableid + _tablecolumn).offset($(# + tableid + _tablelayout).offset());
$(# + tableid + _tabledata).offset($(# + tableid + _tablelayout).offset());
}
$(document).ready(function () {
fixtable(mytable, 2, 600, 200);
});
// ]]>
项目公示栏dddddddd 总分
语文 数学 英语 政治 历史 地理 物理 化学 生物
ss
上线时间
1
29 1
25 2
146
28
79
73
47
8
91 33
526 qq
dd
在线人数
2
29
25
146
28
79
73
47
8
91
526
学生32
班级1
29
25
146
28
79
73
47
8
91
526
学生32
班级1
29
25
146
28
79
73
47
8
91
526
学生32
班级1
29
25
146
28
79
73
47
8
91
526
s
学生32
班级1
29
25
146
28
79
73
47
8
91
526
学生32
班级1
29
25
146
28
79
73
47
8
91
526
学生32
班级1
29
25
146
28
79
73
47
8
91
526
学生32
班级1
29
25
146
28
79
73
47
8
91
526
学生32
班级1
29
25
146
28
79
73
47
8
91
526
其它类似信息

推荐信息