zoukankan      html  css  js  c++  java
  • 【模块】Delaying Javascript Event Execution

    <!DOCTYPE html>
    <html>
    <head>
        <meta charset="UTF-8">
        <title></title>
    </head>
    <body>
        <style type="text/css">
        body{ height:2000px;}
        div{ position:fixed; right:0; width:100px; height:100px; background:#0ff;}
        </style>
        <div id="box1" style="top:0;"></div>
        <div id="box2" style="top:150px;"></div>
        <div id="box3" style="top:300px;"></div>
        <script type="text/javascript" src="jquery-1.5.2.min.js"></script>
        <script type="text/javascript">
        $(function () {
            /*var onFooEndFunc = function () {
                var delay = 50;
                var executionTimer;
                return function () {
                    if (!!executionTimer) {
                        clearTimeout(executionTimer);
                    }
                    executionTimer = setTimeout(function () {        
                    }, delay);
                };
            }();*/    
            var end = function () {        
                var delay = 50, executionTimer;
                return function (outputId) {
                    if (!!executionTimer) {
                        clearTimeout(executionTimer);
                    }
                    executionTimer = setTimeout(function () {                
                        $(outputId).html(++delay);
                    }, delay);
                };
            }();        
            
            $('body').mousemove(function () {
                end('#box1');
            });
            $(window).resize(function () {
                end('#box2');
            });
            $(window).scroll(function () {
                end('#box3');
            });
        });    
        </script>
    </body>
    </html>
  • 相关阅读:
    Codeforces Round #274 (Div. 2)
    codeforces 477C
    ZOJ 3822 Domination
    Codeforces Round #271 (Div. 2)
    进程
    线程
    udp和tcp特点 实现文件上传
    面向对象补1
    socket基本语法和粘包
    网络编程
  • 原文地址:https://www.cnblogs.com/jzm17173/p/2583209.html
Copyright © 2011-2022 走看看