How to detect a long press on a div in Jquery?

前端 未结 12 1385
广开言路
广开言路 2020-12-08 04:44

I would like to execute some function when the user presses for 2 seconds on a div.

Is it possible ?

Here is my code to detect the click on the

12条回答
  •  [愿得一人]
    2020-12-08 05:26

    In the two years since this question was asked an awesome plugin called jQuery Finger was invented:

    http://ngryman.sh/jquery.finger/

    $('div').on('press', function(e) {
        console.log(this, e);
    });
    

提交回复
热议问题