zoukankan      html  css  js  c++  java
  • OOP定时器组

    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>OOP定时器组</title>
        <style type="text/css">
            body {
                margin: 0;
                padding: 0;
            }
            div.container div{
                text-align: center;
                margin: 5px;
                height: 60px;
                width: 100px;
                background: red;
                left: 100px;
            }
        </style>
        <script type="text/javascript">
            function FnGuo(oDiv,num){
                var oDivTemp=null;
                var _this = this;
                for(var i=1;i<=num;i++)
                {
                    oDivTemp = document.createElement("div");
                    oDivTemp.innerHTML = "" + i + "";
                    oDiv.appendChild(oDivTemp);
    
                    oDivTemp.oTimer = null;
                    oDivTemp.nowLength = 100;
    
                    oDivTemp.onmouseover = function(){
                        _this.fnLength(this,500);
                    };
                    oDivTemp.onmouseout = function(){
                        _this.fnLength(this,100);
                    };
                }
            }
    
            FnGuo.prototype.fnLength = function(oDivTemp,tarLength){
                clearInterval(oDivTemp.oTimer);
                var speed = 0;
                oDivTemp.oTimer = setInterval(function(){
                    speed = (tarLength-oDivTemp.nowLength)/6;
                    speed=speed>0?Math.ceil(speed):Math.floor(speed);
                    if(tarLength != oDivTemp.nowLength)
                    {
                        oDivTemp.nowLength += speed;
                        oDivTemp.style.width = oDivTemp.nowLength + "px";
                    }
                    else
                    {
                        //clearInterval(oDivTemp.oTimer);
                    }
                },30);
            };
            window.onload = function(){
                var oDiv = document.getElementsByTagName("div")[0];
                var num = 6;//生成div的个数
                var oFnGuo = new FnGuo(oDiv,num);
            };
        </script>
    </head>
    <body>
        <div class="container"></div>
    </body>
    </html>
    工欲善其事 必先利其器
  • 相关阅读:
    monads-are-elephants(转)
    程序语言简史(转)
    语法的省略不能造成编译器的歧义
    scala getter and setter
    隐式类型转换
    java 调用 scala
    列表的操作
    Scala HandBook
    Scala 高级编程练习
    Net 2.0 C# 专用的只读类Tuple
  • 原文地址:https://www.cnblogs.com/fengyouqi/p/7879284.html
Copyright © 2011-2022 走看看