我创建了一个循环,将“last”类分配给每五个元素,但由于某种原因,.className 似乎不起作用。我最初使用 .class 但 ie7 和 ie8 错误。谁能告诉我如何解决这个问题?
JS 片段
success: function(response) {
var source = $("#calendar-template").html(),
template = Handlebars.compile(source),
gameHTML = '';
for (var i = 0, gameLength = response.data.games.length; i < gameLength; i++){
var thisGame = response.data.games[i];
console.log(thisGame);
thisGame.className = ((i+1) % 5 == 0) ? 'last' : '';
gameHTML += template(thisGame);
}
instance.selectors.dateWrapper.append(gameHTML);
deferredObject.resolve();
instance.displayGames();
},
回复
data: Object
games: Array[18]
0: Object
1: Object
2: Object
3: Object
...
干杯