为什么on和triggerHandler后面可以加auto_move,move_next

为什么on和triggerHandler后面可以加auto_move,move_next

为什么on和triggerHandler后面可以加auto_move,move_next,不是只可以加click,mouseover这类关键字吗?

wrap

.on('move_prev',function(){

if(current<=0){

current = size;

}

current = current - 1 ;

wrap.triggerHandler('move_to',current);

})

.on('move_next',function(){

if( current >= size-1){

current = -1;

}

current = current + 1 ;

wrap.triggerHandler('move_to',current);

})

.on('move_to',function(evt,index){

wrap.css('left',index*width*-1);

tips.removeClass('item_focus').eq(index).addClass('item_focus');

})

.on('auto_move',function(){


setInterval(function(){

enableAuto && wrap.triggerHandler('move_next');

},2000);


})

.triggerHandler('auto_move');


// 事件

btn_prev.on('click',function(){

wrap.triggerHandler('move_prev');

});

btn_next.on('click',function(){

wrap.triggerHandler('move_next');

});

tips.on('click',function(){

var index = $(this).index();

wrap.triggerHandler('move_to',index);

})


正在回答 回答被采纳积分+1

登陆购买课程后可参与讨论,去登陆

2回答
好帮手慕星星 2018-09-07 11:13:34

click和mouseover这些事件是常用的,但是也可以自定义事件,代码中是wrap和triggerHandler绑定了这些自定义的事件,后面元素做点击的事件,或者是其他事件的时候,直接调用就可以了,

http://img1.sycdn.imooc.com//climg/5b91ec9f0001253c06410279.jpg

祝学习愉快~~


提问者 KongSunday 2018-09-07 06:24:54

老师,还有要怎样去理解使用

问题已解决,确定采纳
还有疑问,暂不采纳

恭喜解决一个难题,获得1积分~

来为老师/同学的回答评分吧

0 星
请稍等 ...
意见反馈 帮助中心 APP下载
官方微信

在线咨询

领取优惠

免费试听

领取大纲

扫描二维码,添加
你的专属老师