【多个淡入浅出】函数哪里错了?
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>多个淡入淡出</title>
    <style>
        div{
            width: 100px;
            height: 50px;
            margin: 10px;
            background-color: red;
            filter: alpha(opacity=30);
            opacity: 0.3;
        }
    </style>
    <script type="text/javascript">
    window.onload=function()
    {
        var aDiv = document.getElementsByTagName('div');
        var i = 0;

        for(i=0;i<aDiv.length;i++)
        {   
            aDiv[i].alpha = 30;
            aDiv[i].timer = null;
            aDiv[i].onmouseover=function ()
            {
                startMove(this,100);
            }
            aDiv[i].onmouseout=function ()
            {
                startMove(this,30);
            }            
        }
    }

    function startMove(obj,iTarget)
    {
        clearInterval(obj.timer);
        obj.timer=setInterval(function(){
            var iSpeed = (iTarget-obj.alpha)/8;
            iSpeed=iSpeed>0?Math.ceil(iSpeed):Math.floor(iSpeed);

            if(obj.alpha==iTarget)
            {
                clearInterval(obj.timer);
            }
            else
            {
                obj.alpha+=iSpeed;

                obj.style.filter='alpha(opacity='+obj.alpha+')';
                obj.styel.opacity=obj.alpha/100;
            }
        },30)
    }
    </script>
</head>
<body>
    <div></div>
    <div></div>
    <div></div>
    <div></div>
    <div></div>
</body>
</html>

1个回答

obj.styel.opacity=obj.alpha/100;

style拼写错了

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问