【发布时间】:2019-07-22 04:10:59
【问题描述】:
我正在尝试显示当前月份和年份,但没有显示任何内容。
HTML:
<div id="date"></div>
CSS:
#date {
display: block;
color: black;
font-size: 50px;
top: 50px;
left: 50px;
}
JavaScript:
(function() {
var days = ['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'];
var months = ['January','February','March','April','May','June','July','August','September','October','November','December'];
Date.prototype.getMonthName = function() {
return months[ this.getMonth() ];
};
Date.prototype.getDayName = function() {
return days[ this.getDay() ];
};
})();
var now = new Date();
var day = now.getDayName();
var month = now.getMonthName();
【问题讨论】:
-
为什么你有想要当前月份和年份的日子?
标签: javascript html css google-chrome-extension