代码编辑器:
x
1
<p id="demo">单击按钮显示月份</p>
2
<button onclick="myFunction()">点我</button>
3
<script>
4
function myFunction(){
5
var d = new Date();
6
var x = document.getElementById("demo");
7
x.innerHTML=d.getMonth();
8
}
9
</script>
10
<p><strong>注意:</strong> 0=一月, 1=二月 ,类推</p>
11