为什么不会.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>
要使用left
or top
元素的样式必须是position:absolute
, or position:relative
, or position:fixed
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)