源代码:
下载代码
点击运行
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>菜鸟教程(runoob.com)</title> </head> <body> <p id="demo">返回当前时间的毫秒数:</p> <button onclick="myFunction()">点我</button> <script> function myFunction(){ const currentTime = Date.now(); var x = document.getElementById("demo"); x.innerHTML = currentTime; } </script> </body> </html>
运行结果: