【问题标题】:Typed.js restrict first element from backspaceTyped.js 限制退格的第一个元素
【发布时间】:2015-03-15 03:42:02
【问题描述】:

我有以下 Typed.js 代码 (https://github.com/mattboldt/typed.js/)

js

  $(function(){
     $("h2").typed({
        strings: ["This should stay forever. ", "Loop Element 1", "Loop Element 2", "Loop Element 3"],
        typeSpeed: 0,
        loop: true
    });
});

html

<h2></h2>

css

body{background: #000; color: lime; }
.typed-cursor{opacity: 0;  display:none; }

目前它正在循环运行。这是我的代码CodePen.io

我希望它在循环中运行它,但我希望第一个元素按照它现在的样子出现。一旦它出现,我希望它留下来,然后其余元素将输入和输出,它们将在循环中。

【问题讨论】:

    标签: jquery typed


    【解决方案1】:

    更新:

    刚刚找到答案。这就是我正在做的事情

    js

     $(function(){
        $("h2 .first").typed({
            strings: ["This should stay forever. "],
            typeSpeed: 0,
            callback: function() {
              showThis();
            },
    
        });
    
     function showThis(){
    
        $("span.second").typed({
              strings: ["Loop Element 1", "Element 2 Here", "New Element 3", "Element # 4"],
              backDelay: 1500,    
              typeSpeed: 100,
              backSpeed: 100,
              loop: true,
    
          });
    
      }
    });
    

    css

    body{background: #000; color: lime; }
    
    .typed-cursor{
        display:none;
    }
    

    HTML

    <h2><span class="first"></span><span class="second"></span></h2>
    

    这里是笔码:PenCode

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-01-22
      • 1970-01-01
      • 2013-07-29
      • 2023-03-30
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多