$('li').on('click',function(){
console.log($(this).index())
})
-
-
-
-
-
-
-
-
-
不是点击当前元素的上一个,是比如我第一次点了第3个,第二次点了第7个,我怎么获取到第一次点的位置
$('li').on('click',function(){
console.log($(this).index())
})
var preIndex = -1;
$('li').on('click', function () {
console.log(preIndex)
preIndex = $(this).index()
console.log($(this).index())
})