IMaki
2016-05-09 21:21
window.onload = function(){ var oDiv = document.getElementById('alpha'); oDiv.onmouseover = function(){ startChange(1); }; oDiv.onmouseoout = function(){ startChange(0.3); }; } var timer = null; var alpha = 0.3; function startChange(target){ var oDiv = document.getElementById('alpha'); clearInterval(timer); timer = setInterval(function(){ var speed = 0; if (alpha > target) { speed = -0.03; } else { speed = 0.03; } if (alpha == target) { clearInterval(timer); } else { alpha += speed; oDiv.style.opacity = alpha; } },30) }
我已经知道问题在哪了。。。onmouseover多了个o!!!!!!
JS动画效果
113925 学习 · 1443 问题
相似问题