有没有办法用jquery触发mousedown并保持x秒?

时间:2016-09-11 11:52:26

标签: javascript jquery events

我只是找不到任何提示,任何人都可能知道这样做的方法吗?

编辑:目标是在按钮https://lv-ripple.antoniodalsie.com上触发涟漪效果,使用$('#button').trigger('mousedown')工作,但动画太短,它使用我认为的事件对象中给出的时间戳。

1 个答案:

答案 0 :(得分:-3)

您可以执行以下操作(请参阅http://api.jquery.com/mousedown/):    var interval;     $(按钮).addEventListener('mousedown',function(e){         interval = setInterval(function(){         },500);     });     $(button)。addEventListener('mouseup',function(e){         clearInterval(间隔);     });     $(按钮).addEventListener('mouseout',function(e){         clearInterval(间隔);     });