编辑下面的代码:【加编码】
<html> <body> <p id="demo">Click the button to display the monthname, according to UTC.</p> <button onclick="myFunction()">Try it</button> <script> function myFunction() { var d=new Date(); var month=new Array(12); month[0]="January"; month[1]="February"; month[2]="March"; month[3]="April"; month[4]="May"; month[5]="June"; month[6]="July"; month[7]="August"; month[8]="September"; month[9]="October"; month[10]="November"; month[11]="December"; var x = document.getElementById("demo"); x.innerHTML=month[d.getUTCMonth()]; } </script> <p><strong>Note:</strong> 0=January, 1=February, Etc.</p> </body> </html>
结果: 【此窗口】 帮助?
Try it Yourself - © 自强学堂