另一个简单计数
- <!DOCTYPE html>
- <html>
- <body>
- <button onclick="timedText()">试一试</button>
- <p id="demo">点击“试一试”。我将在两秒,四秒和六秒过后显示。</p>
- <script>
- function timedText() {
- setTimeout(myTimeout1, 2000)
- setTimeout(myTimeout2, 4000)
- setTimeout(myTimeout3, 6000)
- }
- function myTimeout1() {
- document.getElementById("demo").innerHTML = "2 秒";
- }
- function myTimeout2() {
- document.getElementById("demo").innerHTML = "4 秒";
- }
- function myTimeout3() {
- document.getElementById("demo").innerHTML = "6 秒";
- }
- </script>
- </body>
- </html>