我正在建立我的小日曆與純JavaScript(所以請不要jquery),我有麻煩,使前月顯示 到目前爲止,這是我的代碼獲取上個月:日曆繼續得到前一個月
document.getElementById("prev-month").addEventListener("click", function(e) {
console.log('first', prevMonth);
prevMonth = monthNamesArray[currentMonth - 1]; //Array with all the month labels like ['Jan', 'Feb', 'Mar'];
month.innerHTML = '<td>'+ prevMonth +'</td>'; //Here i replace the html cell where the month is display
console.log('second', prevMonth);
});
兩個調試程序的執行console.log是: 首先點擊:第一未定義第二九月(比上月) 第二點擊:第一九月第二月
爲什麼在第二點擊第二個控制檯日誌沒有成爲第二個八月? 爲什麼prevMonth只會回到一個月?
任何幫助,特別的解釋,是真正的讚賞
啊哈!謝謝!我怎麼看不到它! – 2014-10-05 20:18:58