是否有一种方法可以用jquery触发鼠标按下并保持x秒?

Is there a way to trigger mousedown with jquery and hold it for x seconds?

本文关键字:鼠标 jquery 一种 方法 是否      更新时间:2023-09-26

我就是找不到任何关于这方面的技巧,有人知道怎么做吗?

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

您可以这样做(参考http://api.jquery.com/mousedown/):

)
   var interval;
    $(button).addEventListener('mousedown',function(e) {
        interval = setInterval(function() {
        },500); 
    });
    $(button).addEventListener('mouseup',function(e) {
        clearInterval(interval);
    });
    $(button).addEventListener('mouseout',function(e) {
        clearInterval(interval);
    });