Bab*_*ker 2 javascript css javascript-events
为什么不能.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>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4991 次 |
| 最近记录: |