目前我在表格中显示各种天气参数,我还希望当天和接下来的六天在第一列中。
我开始像这样创建工作日:
// Make variables for every weekday
var d = new Date();
var weekday = new Array(7);
weekday[0] = "Sunday";
weekday[1] = "Monday";
weekday[2] = "Tuesday";
weekday[3] = "Wednesday";
weekday[4] = "Thursday";
weekday[5] = "Friday";
weekday[6] = "Saturday";
var today = d.getDay();
我的桌子看起来像这样。
$('#weakly-table').append('<tr><td>Day</td><td>Temperature</td> <td>Description</td> <td> Pressure </td> <td> Humidity </td> <td> Wind speed </td> </tr>')
$.each(weaklyWeather.list, function(index, weather) {
$('#weakly-table').append('<tr><td>' + weekday[today] + '</td><td>' + Math.round(weaklyWeather.list[index].temp.day) + '°C  </td> <td> <img src="http://openweathermap.org/img/w/'+ weaklyWeather.list[index].weather[0].icon+'"/>' + '</td> <td>' + Math.round(weaklyWeather.list[index].pressure) + ' Pa' + '</td><td>' + Math.round(weaklyWeather.list[index].humidity) + ' %' + '</td><td>' + Math.round(weaklyWeather.list[index].speed) + ' m/s' + '</td></tr>');
而不是在每一行的第一列中写 weekday[today] 我希望它是 weekday[today + 1]、weekday[today + 2] 等等,但这只会给我每一行的第二天。
有什么建议么?