【发布时间】:2010-11-18 16:05:34
【问题描述】:
为什么.style.top = "200px"; 不能在这段代码中工作?使用oclick="this.style.left='200px';" 在元素内调用事件也不起作用。
<html>
<head>
</head>
<body>
<div id="theDiv">The Div</div>
<button id="theButton">Do</button>
</body>
</body>
</html>
<script type="text/javascript">
document.getElementById("theButton").onclick = function(){
document.getElementById("theDiv").style.top = "200px";
};
</script>
【问题讨论】:
-
每个元素的
position设置是什么?
标签: javascript css javascript-events