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