html table內容不隨標題滾動
<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>