x
1
<p id="demo">单击按钮来调用新的myMet()方法,并显示这个月的月份,,使用新的myProp方法</p>
2
<button onclick="myFunction()">点我</button>
3
<script>
4
Date.prototype.myMet = function() {
5
if (this.getMonth() == 0) {
6
this.myProp = "一月"
7
};
8
if (this.getMonth() == 1) {
9
this.myProp = "二月"
10
};
11
if (this.getMonth() == 2) {
12
this.myProp = "三月"
13
};
14
if (this.getMonth() == 3) {
15
this.myProp = "四月"
16
};
17
if (this.getMonth() == 4) {
18
this.myProp = "五月"
19
};
20
if (this.getMonth() == 5) {
21
this.myProp = "六月"
22
};
23
if (this.getMonth() == 6) {
24
this.myProp = "七月"