zoukankan      html  css  js  c++  java
  • [jQuery编程挑战]006 生成一个倒计时效果

    <!DOCTYPE html>
    <html lang="zh">
        <head>
            <meta charset="utf-8"/>
            <title>生成一个倒计时效果</title>
            <style type="text/css">
                body{
                    margin:0;
                    padding:0;
                    background: orange;
                    width: 100%;
                    height: 100%;
                    font-size: 5em;
                    color: #fff;
                    text-align:center;
                    font-family: 'microsoft yahei',Arial,sans-serif;
                }
                .countdown{
                    position: absolute;
                    top:50%;
                    left:50%;
                    transform: translate(-50%,-50%);
                    -webkit-transform: translate(-50%,-50%);
                }
            </style>
            <script type="text/javascript" src="../js/jquery-1.11.0.js"></script>
            <script type="text/javascript">
                $(function() {
                    var $countdown = $('.countdown'),
                            number = $countdown.html() * 100 / 100;
                        //number = parseInt($countdown.html());
                    var countdownInterval = window.setInterval(function() {
                        number--;
                        if (number == 0) {
                            $countdown.html("你好,涂传龙");    
                            window.clearInterval(countdownInterval);
                        } else {
                            $countdown.html(number);
                        }
                    }, 1000);
                });
            </script>
        </head>
        <body>
            <div class="countdown">
                60
            </div>
        </body>
    </html>
  • 相关阅读:
    python迭代器
    初识html
    跨域(jsonp)方法
    闭包
    pycharm软件配置
    插槽slot
    git常用操作
    在mac中使用Charles抓包操作
    防止网页被嵌入框架
    H5唤起APP
  • 原文地址:https://www.cnblogs.com/jerry19890622/p/4309891.html
Copyright © 2011-2022 走看看