1 <!DOCTYPE html> 2 <html> 3 <body> 4 5 <p>点击按钮就可得到一个时钟</p> 6 7 <button onclick="displayDate()">click here!</button> 8 9 <script> 10 function displayDate() 11 { 12 document.getElementById("demo").innerHTML=Date(); 13 window.setInterval("displayDate()",1000); 14 } 15 16 </script> 17 18 <p id="demo"></p> 19 20 </body> 21 </html>
时间: 2024-10-28 14:23:00