W3School TIY Editor
W3School 在线教程
改变方向
暗黑模式
运行代码
<!DOCTYPE html> <html> <body> <button onClick="setInterval(myCounter, 1000)">启动计数器</button> <p id="demo">点击上面的按钮,我会永远计数。</p> <script> var c = 0; function myCounter() { document.getElementById("demo").innerHTML = ++c; } </script> </body> </html>