/*html*/
<div class="arrow arrow_left" onclick="changeindex(-1);"></div>
<div class="arrow arrow_right" onclick="changeindex(1)"></div>
/*javascript*/
var this_index = 0; //設定一個初始0的整數
function changeindex(change){
this_index = (this_index+change+7)%7;
console.log(this_index)
}
邏輯是(例如):
30%30=>0
31%30=>1
32%30=>2
33%30=>3
7的部分要看你的slider的lenght(長度)而定,
如此一來按左右兩箭頭就能判斷slider當前的index囉!進而寫出輪播器效果