源代碼
點擊運行
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>教程</title> </head> <body> <p id="demo">單擊按鈕顯示1970年1月1號至今的毫秒數。</p> <button onclick="myFunction()">點我</button> <script> function myFunction(){ var d = new Date(); var x = document.getElementById("demo"); x.innerHTML=d.getTime(); } </script> </body> </html>
運行結果