// var next=document.getElementsByClassName('nextPage'); var next = document.getElementById('nextPage'); var prev = document.getElementById('prevPage'); var items = document.getElementsByClassName('bg-item'); var items2 = document.getElementsByClassName('bg-item2'); var index = 0; // console.log(items); function btnNext() { index++; if (index > 3) index = 3; console.log(index); ShowItems(); ShowItems2(); }; function btnPrev() { index--; if (index < 0) index = 0; console.log(index); ShowItems(); ShowItems2(); }; // next.onclick = btnNext; // prev.onclick = btnPrev; console.log(items) function ShowItems() { // 迴圈執行,將每張項目的類別bg-active移除 for (var i = 0; i