$(document).ready(function() {
var dataText = ["Text on line one <br /> Text on line 2"];
function typeWriter(text, i, fnCallback) {
if (i < (text.length)) {
document.querySelector(".animate").innerHTML = text.substring(0, i+1) +'<span aria-hidden="true"></span>';
setTimeout(function() {
typeWriter(text, i + 1, fnCallback)
}, 75);
}
else if (typeof fnCallback == 'function') {
}
}
function StartTextAnimation(i) {
if (typeof dataText[i] == 'undefined'){
setTimeout(function() {
StartTextAnimation(0);
}, 20000);
}
if (i < dataText[i].length) {
setTimeout(function() {
typeWriter(dataText[i], 0, function(){
StartTextAnimation(i + 1);
});
}, 1000);
}
}
StartTextAnimation(0);
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<p class="animate"></p>
,你可以看到,在“<”被印在很短的时间内,有没有什么办法来防止这种情况?添加HTML代码的休息,从JS代码删除它不起作用
我没有看到它印 – Lixus
如果只是关闭,因为尽管StackOverflow上的,通知您在这里发布的代码,你没有。 –
打印时间很短 – Celice