jquery固定表头方法
精选
转载
js:
<script>
//固定表头开始
$(document).ready(function(){
dh_fd();
});
functiondh_fd(){
var hight = document.body.scrollHeight;
hight = hight-0;
if($(window).scrollTop() >= 120 && $(window).scrollTop()<=hight ){
$(".xx_dh_fd").show();
}else{
$(".xx_dh_fd").hide();
}
}
functionTop() {
$("html, body").animate({scrollTop : 0 }, 120);
}
$(window).scroll(function() {dh_fd();});
$(window).resize(function(){dh_fd();});
//固定表头结束
</script>
样式:
.xx_dh_fd{
background:#ffffff;
left:auto;top:0px;
display:none;
position:fixed;z-index:9999999;
width:98%;
_position:absolute;/*IE6*/
_width:98%;/*IE6*/
}
加一个需要隐藏的表头
//固定的表头
<tabale id="id1" class="xx_dh_fd"><tabel>
//要固定的表头
<tabale id="id2"><tabel>