zoukankan      html  css  js  c++  java
  • jquery打字机效果

    html代码

    <div id="box">
        <div id="content">
            <div id="code">
                如果你认识以前的我,那么你会原谅现在的我。
            </div>
        </div>
    </div>    

    css代码

    body{margin:0;padding:0;background:#ffe;font-size:12px;overflow:auto}
    #mainDiv{width:500px;height:100%;margin: 0 auto;margin-top: 100px;}
    #code{float:left;width:440px;height:400px;color:#333;font-size:12px;margin:200px 0 0 200px;}

    js代码

    <script type="text/javascript">
      (function($) {
        $.fn.typewriter = function() {
          this.each(function() {
          var $ele = $(this), str = $ele.html(), progress = 0;
          $ele.html('');
          var timer = setInterval(function() {
          var current = str.substr(progress, 1);
          if (current == '<') {
            progress = str.indexOf('>', progress) + 1;
          } else {
            progress++;
          }
          $ele.html(str.substring(0, progress) + (progress & 1 ? '_' : ''));
          //if (progress >= str.length) {
          //clearInterval(timer);
          //}
        }, 100);
      });
      return this;
      };
      })(jQuery);
      $(function(){
        $("#code").typewriter();
      })
    </script>
  • 相关阅读:
    【pytest学习10】fixture参数化,fixture(params=data)装饰器的data是函数返回值yield request.param ,将带到下面调用为参数的函数中
    Pipfile 文件转换利器——pipfile-freeze
    npm的lock
    调试wmi连接主机进行监控
    RPC电源监控总结
    HTTP协议三次握手过程
    linux常用命令集
    Gym
    Gym
    实验2.2
  • 原文地址:https://www.cnblogs.com/lixiaoxing/p/5026410.html
Copyright © 2011-2022 走看看