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); });
