Javascript 冻结响应表的第一列
我有一个响应表,我想冻结它的第一列。我从堆栈溢出中获取引用,并在表上尝试代码 CSS代码:Javascript 冻结响应表的第一列,javascript,jquery,css,html-table,Javascript,Jquery,Css,Html Table,我有一个响应表,我想冻结它的第一列。我从堆栈溢出中获取引用,并在表上尝试代码 CSS代码: .table-responsive>.fixed-column { position: absolute; display: inline-block; width: auto; border-right: 1px solid #ddd; } jQuery代码: $(function(){ var $table = $('.table'); //Ma
.table-responsive>.fixed-column {
position: absolute;
display: inline-block;
width: auto;
border-right: 1px solid #ddd;
}
jQuery代码:
$(function(){
var $table = $('.table');
//Make a clone of our table
var $fixedColumn = $table.clone().insertBefore($table).addClass('fixed-column');
//Remove everything except for first column
$fixedColumn.find('th:not(:first-child),td:not(:first-child)').remove();
//Match the height of the rows to that of the original table's
$fixedColumn.find('tr').each(function (i, elem) {
$(this).height($table.find('tr:eq(' + i + ')').height());
});
});
但是,这段代码不起作用,有人能告诉我如何使它起作用吗,请在完成代码,这段代码起作用:,您缺少表变量冻结在这种情况下意味着什么?固定尺寸(宽度)?不可编辑的内容?@BhavO你能告诉我为什么第一列显示为不可见,我能做得更多吗prominent@hoijui冻结的意思是,第一列应该保持固定,其余的列应该允许滚动horizontally@kavi我已将桌面背景颜色设置为白色,请看此功能:,您缺少表变量冻结在这种情况下是什么意思?固定尺寸(宽度)?不可编辑的内容?@BhavO你能告诉我为什么第一列显示为不可见,我能做得更多吗prominent@hoijui冻结的意思是,第一列应该保持固定,其余的列应该允许滚动horizontally@kavi我已经将桌面背景颜色设置为白色,请看一看