W3School TIY Editor
W3School 在线教程
改变方向
暗黑模式
运行代码
<!DOCTYPE html> <html> <body> <p>单击该按钮可在更改年、月、日后显示日期。</p> <button onclick="myFunction()">试一试</button> <p id="demo"></p> <script> function myFunction() { var d = new Date(); d.setFullYear(2020, 10, 3); document.getElementById("demo").innerHTML = d; } </script> <p><strong>Note:</strong> Remember that JavaScript counts months from 0 to 11. Month 10 is November.</p> </body> </html>