最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

JavascriptJquery, disabling all double clicks anywhere within body of web page? - Stack Overflow

matteradmin7PV0评论

I already have a lot of AJAX code written for a web app and didn't take into account the problems that double clicks on some things can cause. I already implemented an "inprogress" variable for sensitive AJAX calls so that it won't be messed up by double clicking by the user but I am wondering if there is a simple way to just disable all double clicks anywhere (in any element) within the entire body of the web page rather than having to do it individually for each specific element.

Thanks for any advice

I already have a lot of AJAX code written for a web app and didn't take into account the problems that double clicks on some things can cause. I already implemented an "inprogress" variable for sensitive AJAX calls so that it won't be messed up by double clicking by the user but I am wondering if there is a simple way to just disable all double clicks anywhere (in any element) within the entire body of the web page rather than having to do it individually for each specific element.

Thanks for any advice

Share Improve this question asked May 6, 2011 at 1:14 RickRick 17k35 gold badges113 silver badges163 bronze badges 2
  • did you actually mean 'double-clicking' in the meaning of two clicks w/ almost no pause between them, or clicking 2+ times on a button that is wired to an ajax call and thus would add another call on top of the old on, and so on....? – ampersand Commented May 6, 2011 at 2:45
  • 1 I mean double clicking like when you have to double click something on a windows desktop icon to open an application / file. While I don't do it myself, some of our users have problems with this action being ingrained in them so they double click everything on the web app – Rick Commented May 6, 2011 at 20:43
Add a ment  | 

3 Answers 3

Reset to default 5

Try something crazy like this:

$("*").dblclick(function (event)
{
    event.preventDefault();
});

In theory, it would capture the double-click event on any element and then basically do nothing (cancels the default action).

$('*').dblclick(function(event) { event.preventDefault(); return false; });

Should handle it, however there is probably a better solution out there.

If you havn't bound events to double click, double click will do nothing. It is event of its own.
Click and DoubleClick are different events.

Articles related to this article

Post a comment

comment list (0)

  1. No comments so far