jQuery的click和on方法(参数如果用箭头函数,就不起效果,参数只能用原生写,写jQuery轮播图试出来的)

282 阅读1分钟
  $('#focus li').click(function(){
            var curIndex=$(this).index();
            step=curIndex;
            renderImgs();
            renderFocus();
        });
//第一种情况
 $('#focus li').click(function(){//如果变成箭头函数的话就不起效果
            var curIndex=$(this).index();
            step=curIndex;
            renderImgs();
            renderFocus();
        });
        
//第二种情况
 $('#focus li').on('click',function(){//如果变成箭头函数的话就不起效果
            var curIndex=$(this).index();
            step=curIndex;
            renderImgs();
            renderFocus();
        });