我有以下用于类型化的代码.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
我希望它在循环中运行它,但我希望第一个元素按当前显示的方式显示。一旦它出现,我希望它保留,然后其余元素将输入和输入出来,它们将在循环中。
更新:
刚想出答案。这是我正在做的
.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>
这是笔代码: 笔代码