let s = 0
let dsq
let arr = [0, 1, 2, 5, 8, 7, 6, 3]
$('.ks').click(function (e) { // 1 点击开始
e.preventDefault()
clearTimeout(dsq) //每次点击的时候都要先清除上次的定时器
dsq = setInterval(fn, 50) //3 执行这个定时器 s会在50毫秒加一
function fn() {
if (s == arr.length) { s = 0 } // 4当S大于数组的长度 让s归零
// if (s > arr.length-1) { s = 0 }
// 因为转盘的方向是顺时针 所以做一个数组 顺序为 li的模拟索引
$('ul li').eq(arr[s]).addClass('on').siblings().removeClass('on')
// 只有数组ARR[n]个的样式为 on 除自身之外的所有兄弟样式删除on
s++ // 2让 s这个数字+1
}
})
$('.tz').click(function (e) {
e.preventDefault() //点击停止的时候 清楚定时器
clearTimeout(dsq)
})