offsetLeft与offsetParent,scrollLeft

 

<script>
function move()
{
var d=document.getElementById("d");
a=eval(40);
d.scrollLeft+=a;
alert(d.scrollLeft);
}
</script>
<input type="button" value="点一下" onclick="move()">
<div id="d" style="background-color:#ff9966; position: absolute ; left:170px; top:300px;width:300;height:300;overflow:scroll;"
onclick="alert('offsetLeft-d:'+this.offsetLeft)" >绝对的
<div style="height:600;width:600;background-color:#ff0000;position: relative ;" onclick="alert('offsetLeft:'+this.offsetLeft +' offsetParent:'+this.offsetParent.id)">

相对的</div>
</div>
posted @ 2011-08-24 20:30  zicheng_307  阅读(205)  评论(0编辑  收藏  举报