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>
  • 相关阅读:
    Java EE
    C++基础学习(二)之判断
    C++基础学习(一)之循环
    AutoCAD完全卸载
    point-cloud-annotation-tool编译发烧记_UBUNTU
    Ubuntu18.04安装QT5
    Ubuntu安装VTK-8.1
    常用Latex公式代码表[持续更新]
    shp矢量文件批处理裁剪栅格影像_IDL/ENVI
    摄影测量基本原理
  • 原文地址:https://www.cnblogs.com/lixiaoxing/p/5026410.html
Copyright © 2011-2022 走看看