您的位置:首页 > Web前端 > JavaScript

js 本月,下一月,上一月

2015-11-25 17:30 555 查看
<script type="text/javascript">
var curMonth = new Date();
function initDate() {
var month = curMonth.getFullYear() + '年' + (curMonth.getMonth() + 1) + '月';
document.getElementById('month').innerHTML = month;
}
//上一月
function preMonth() {
var month = curMonth.getMonth() - 1;
curMonth.setMonth(month);
initDate();
}
//下一月
function nextMonth() {
var month = curMonth.getMonth() + 1;
curMonth.setMonth(month);
initDate();
}
//本月
function currentMonth() {
curMonth = new Date();
initDate();
}
</script>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: