我想在我的网站上的一些 div 中放置 5 个即将到来的日期名称。我已经为日期名称创建了数组,然后我从中调用值并添加天数。该方法仅适用于前一天,然后数组结束,从第 2 天到第 5 天它回显“未定义”。
请帮忙?
var weekday=new Array(7);
weekday[0]="Nedelja";
weekday[1]="Ponedeljek";
weekday[2]="Torek";
weekday[3]="Sreda";
weekday[4]="Četrtek";
weekday[5]="Petek";
weekday[6]="Sobota";
var dan = weekday[today.getDay()];
var dan_1 = weekday[today.getDay()+1];
document.getElementById("day1").innerHTML = dan_1;
var dan_2 = weekday[today.getDay()+2];
document.getElementById("day2").innerHTML = dan_2;
var dan_3 = weekday[today.getDay()+3];
document.getElementById("day3").innerHTML = dan_3;
var dan_4 = weekday[today.getDay()+4];
document.getElementById("day4").innerHTML = dan_4;
var dan_5 = weekday[today.getDay()+5];
document.getElementById("day5").innerHTML = dan_5;
谢谢你们!