将 class 添加到具有特定 class 的第二个项目
Adding a class to every second item with that has specific class
它有效,但 JShint 在最后一行给我一个错误 Unexpected ' '。 这就是为什么我无法使用 gulp 和整个事情进行编译的原因崩溃。
var yearData = document.querySelectorAll(".timeline-years .have-data");
for (var i = 0, length = yearData.length; i < length; i++) {
if (i % 2 == 0) {
yearData[i].classList.add("bottom-year");
}
}
不确定这里的致命缺陷是什么?
您在第 5 行有尾随 Zero-width space character。
删除它,您的代码将 运行。
它有效,但 JShint 在最后一行给我一个错误 Unexpected ' '。 这就是为什么我无法使用 gulp 和整个事情进行编译的原因崩溃。
var yearData = document.querySelectorAll(".timeline-years .have-data");
for (var i = 0, length = yearData.length; i < length; i++) {
if (i % 2 == 0) {
yearData[i].classList.add("bottom-year");
}
}
不确定这里的致命缺陷是什么?
您在第 5 行有尾随 Zero-width space character。
删除它,您的代码将 运行。