我有 5 个文本节点,例如
<h2 class="textillate"> test </h2>
<h2 class="textillate"> test </h2>
<h2 class="textillate"> test </h2>
<h2 class="textillate"> test </h2>
<h2 class="textillate"> test </h2>
当前一个节点完成时,我想一个一个地对这些节点进行文本化。
我尝试过,但没有成功:(
$(document).ready(function() {
nodes = $('.textillate');
nodes.eq(0).textillate()
.eq(1).textillate();
});
最佳答案
您可以使用函数参数,即initialDelay
。例如,这可以解决问题:
nodes = $('.textilate');
nodes.each(function(index, element){
$(element).textillate({initialDelay: index*1000});
}
查看更多usage options更精细地调整各种持续时间。
更新
这是一个更新的演示,取决于字符串的长度:http://jsfiddle.net/LUq39/13/它实际上累积了延迟时间:
var nodes = $('.textilate');
var delay = 0
nodes.each(function(){
delay += $(this).prev()? $(this).prev().text().length*50:0;
$(this).textillate(
{initialDelay: delay, in:{delay:50}, out:{delay:50}}
);
})
关于javascript - 上一个完成时 jQuery 启动函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19015599/