• js运动 淡入淡出


    <!doctype html>
    <html>
    <head>
    <meta charset="utf-8">
    <title>无标题文档</title>
    <style>
    img{
        margin-left: 200px;
        opacity: 0.3;
        alpha(opacity = 30);
        }
    </style>
    
    <script>
        window.onload = function ()
        {
            var oimg = document.getElementById('img1');
            var timer = null;
    
            oimg.onmouseover = function ()
            {
                touming(this,100,10)
            }
    
            oimg.onmouseout = function ()
            {
                touming(this,30,-10);
            }
    
            function touming(obj,target,speed)
            {
                clearInterval(timer);
    
                timer = setInterval(function ()
                    {
                        var icur = Math.round(css(obj,'opacity')*100);
                        if(icur == target)
                        {
                            clearInterval(timer);
                        }
                        else
                        {
                            obj.style.opacity = (icur + speed)/100;
                            obj.style.filter = 'alpha(opacity= '( + icur + speed ) + ')';
                        }
                    },30);
                
            }
    
            function css(obj,attr)
            {
                if(obj.currentStyle)
                    return obj.currentStyle[attr];
                else
                    return getComputedStyle(obj,false)[attr];
            }
        }
    </script>
    </head>
    
    <body>
    <img id="img1" src="img/1.jpg" alt="图片">
    </body>
    </html>
  • 相关阅读:
    dfssvc.exe
    我左边的公告
    再做了一个LOGO
    做一个调查,请大家帮忙
    如果年三十没有人陪我
    我喜欢这个模版
    cisvc.exe是什么服务
    IIS与SQL服务器安全加固
    终于申请到了blogs
    重发LOGO
  • 原文地址:https://www.cnblogs.com/mayufo/p/4324782.html
Copyright © 2020-2023  润新知