用js给ol中li加相同的current,结果前面的类名失效了
for (var i = 0; i < ul.children.length; i++) {
var li = document.createElement('li');
li.setAttribute('index',i);
ol.appendChild(li);
li.addEventListener('click', function () {
for (var i = 0; i < ul.children.length; i++) {
ol.children[i].className = '';
}
this.className = 'current';
var index = this.getAttribute('index');
num = circle = index;
animat(ul, - index * focusWidth);
})
}
ol.children[0].className = 'current';
var cloneFirst = ul.children[0].cloneNode(true);
ul.appendChild(cloneFirst);
var num = 0
var circle = 0;
arrow_r.addEventListener('click', function () {
if (num == ul.children.length - 1) {
ul.style.left = 0;
num = 0;
}
num++;
animat(ul, -num * focusWidth);
circle++;
if (circle == ol.children.length){
circle = 0;
}
for (var i = 0; i < ol.children.length; i++) {
ol.children[i].className = '';
}
ol.children[i].className = 'current';
})