javascript平时小例子①(移动的小div)
css样式:
#box{
width: 300px;
height: 300px;
background: deepskyblue;
position: absolute;
margin-right: 20px;
}
html布局:
<div id="box"></div>
js部分:
window.onload=function(){
abc();
setInterval(abc,50)
function abc(){
var oDiv=document.getElementById("box");
oDiv.style.left=oDiv.offsetLeft+10+"px";
}
}