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

});


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM