<li id="test"/></li>
<script>
var txtArr = ['热烈欢迎!'], x = 1, y = 0, txt = txtArr[y], timer = null, timer1 = null, cue = $('#test'); 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();
</script>