嗨,我是javascript的新手,我试图弄清楚在分配的时间后如何追加字符串。

After 3 secs append string (How)
After 3 secs append string (are)
After 3 secs append string (you)
After 3 secs append string (?)


感谢:D

最佳答案

<html>
    <head></head>
    <body>
        <span id="mySpan"></span>
    </body>
    <script>
        setTimeout('document.getElementById("mySpan").innerHTML += "How ";', 3000);
        setTimeout('document.getElementById("mySpan").innerHTML += "are ";', 6000);
        setTimeout('document.getElementById("mySpan").innerHTML += "you";', 9000);
        setTimeout('document.getElementById("mySpan").innerHTML += "?";', 12000);
    </script>
</html>

关于javascript - JavaScript自动更改字符串,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/5877813/

10-11 21:11