js表头标题固定

1.

//表头跟踪固定(按钮与表头)var trObj = $("#zdy_id").find("tr:eq(3)");//自定义zdy_id,处于第3行var trObjChild = $(trObj).children();var topValue = 0;var trObj_hj = $("#zdy_id").find("tr:eq(4)");var trObjChild_hj = $(trObj_hj).children();trObjChild.css({ position: "relative", "z-Index": 999 });trObjChild_hj.css({ position: "relative", "z-Index": 999 });$("#scrollDiv").scroll(function () {//默认 topValue = $(this).attr("scrollTop"); if (topValue <= 21) { topValue = 0; } else { topValue = topValue - 110;//这个高度可自己设置 } setTimeout(function () { trObjChild.css({ top: topValue + "px" }); trObjChild_hj.css({ top: topValue + "px" }); }, 0);});

相关文章