有人可以帮助我吗,我根本不懂JS,我想在一页中使用两次。
有人可以给我正确的编码吗
<div id="myTypingText"></div>
<script type = "text/javascript" language = "javascript" >
{
var myString = "Here is my text.";
var myArray = myString.split("");
var loopTimer;
function frameLooper() {
if (myArray.length > 0) {
document.getElementById("myTypingText").innerHTML += myArray.shift();
} else {
clearTimeout(loopTimer);
}
loopTimer = setTimeout('frameLooper()', 70);
}
frameLooper();
}
</script>
答案 0 :(得分:0)
function fun(){
var myString = "Here is my text.";
var myArray = myString.split("");
var loopTimer;
function frameLooper() {
if(myArray.length > 0) {
document.getElementById("myTypingText").innerHTML += myArray.shift();
} else {
clearTimeout(loopTimer);
}
loopTimer = setTimeout('frameLooper()',70);
}
frameLooper();
}
fun()// first call
fun()// second call