标签:tab overflow dem cell scrolltop col 中国 func this
<html>
<head>
</head>
<body>
<div>
<div id="demo" style="overflow:auto;height:80px;width:100;position:relative" onscroll="vertical(this)">
<table border="1" style="position:absolute;z-index:2; " bgcolor=#ff00ff width=100% id=t0>
<tr>
<td id="td1">ttt</td>
<td>ttt中国人</td>
<td>ttt</td>
<td>ttt</td>
<td>ttt</td>
</tr>
</table>
<table border="1" cellpadding="1" height="200" bgcolor=#00ff00 width=100% id=t1 style="position:absolute;z-index:0;">
<tr id="tr1">
<td>asf卡拉挖</td>
<td>asfdd</td>
<td>ddasf</td>
<td>ddasf</td>
<td>ddasf</td>
<td>ddasf</td>
</tr>
<tr id="tr1">
<td>asf卡拉挖</td>
<td>asfdd</td>
<td>ddasf</td>
<td>ddasf</td>
<td>ddasf</td>
<td>ddasf</td>
</tr>
<tr id="tr1">
<td>asf卡拉挖</td>
<td>asfdd</td>
<td>ddasf</td>
<td>ddasf</td>
<td>ddasf</td>
<td>ddasf</td>
</tr>
</table>
</div>
</div>
<script>
var t0 = document.getElementById(‘t0‘);
function vertical(obj) {
console.log(obj.scrollTop); //该函数未定义
console.log(this.scrollTop);
console.log(obj.scrollLeft);
//console.log(this); //this 是windows对象
t0.style.top = obj.scrollTop;
}
</script>
</body>
</html>
标签:tab overflow dem cell scrolltop col 中国 func this
原文地址:https://www.cnblogs.com/enych/p/9895509.html