-3

有人可以帮助我吗,我根本不懂 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>
4

1 回答 1

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 
于 2013-05-15T19:42:27.237 回答