2-1 js速度动画

<html>

<head>

<title>动画效果</title>

<meta charset="utf-8" />

<style>

body,div,span{

margin: 0;

padding: 0;

}

#div1{

background-color:red;

width: 200px;

height: 200px;

border-radius: 15px;

border: 2px purple solid;

top:0;

position: relative;

left: -200px;

}

#div1 span{

background-color: palevioletred;

width: 20px;

height: 50px;

 left:200px;

 top: 70px;

border: 2px white solid;

position: absolute;

}

</style>

<script>

window.onload = function(){

var oDIV = document.getElementById('div1');

oDIV.startMouseover = function(){

startMove();

}

}

function startMove(){

var oDIV = document.getElementById('div1');

setInterval(function(){

oDIV.style.left = oDIV.offsetLeft + 10 + 'px';

},30)

}

</script>

</head>


<body>

<div id="div1"><span id="share">点击</span></div>

</body>


</html>



为什么上面代码,不会出现动画效果呢,鼠标移上去没有动画效果出现,可是没发现代码有什么错误

慕斯2134027
浏览 1146回答 1
1回答
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

JavaScript