javascript逐字输出案例
//动态文字提示
var txtArr = ['欢迎开发者', '专注Web前端开发与PHP编程设计'],
x = 1,
y = 0,
txt = txtArr[y],
timer = null,
timer1 = null,
cue = $('.menutext');
function changTxt() {
if (x == txt.length+1) {
clearTimeout(timer1);
timer1 = setInterval(function(){
y += 1;
if (y > txtArr.length - 1) y = 0;
cue.text('');
txt = txtArr[y];
x=0;
},5500);
}
cue.text(txt.substring(0,x));
x+=1;
clearTimeout(timer);
timer = setTimeout(function(){
changTxt();
},600);
}
changTxt(); 原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。