东经113北纬27
2018-07-31 16:44
<!DOCTYPE html>
<html>
<head>
<title>透明度动画</title>
<style type="text/css">
body,div{margin: 0;padding: 0;}
#div1
{
width: 200px;
height: 200px;
background: red;
opacity: 0.3;
}
</style>
<script type="text/javascript">
window.onload = function(){
var oDiv = document.getElementById('div1')
oDiv.onmouseover = function(){
startMove(10,100);
oDiv.onmouseout = function(){
startMove(-10,30);
}
}
var timer = null;
var alpha = 30;
function startMove(speed,iTarget){
clearInterval(timer);
var oDiv = document.getElementById('div1')
timer = setInterval(function(){
if (alpha==iTarget) {
clearInterval(timer);
}
else {
alpha+=speed;
oDiv.style.opacity = alpha/100;
}
},30)
}
</script>
</head>
<body>
<div id="div1"></div>
</body>
</html>
oDiv.onmouseover = function(){
startMove(10,100);
oDiv.onmouseout = function(){
startMove(-10,30);
}
}
这里错了 没{}对。应该是
oDiv.onmouseover = function(){
startMove(10,100);
}
oDiv.onmouseout = function(){
startMove(-10,30);
}
你这个</script>上面少了一个}
求大佬们帮我看一下 我检查了好久都查不出来
我用的是谷歌浏览器
JS动画效果
113925 学习 · 1443 问题
相似问题