Home > Web Front-end > JS Tutorial > Conflict handling sample code for click and double-click events_jquery

Conflict handling sample code for click and double-click events_jquery

WBOY
Release: 2016-05-16 16:53:33
Original
1129 people have browsed it

First enter the code:

Copy the code The code is as follows:


< ;title>




jQuery namespace


The effect is as shown in the picture. When I double-click, two click events will be triggered first. What's going on? Also, if I don’t want to trigger the

click event when double-clicking, but only trigger the double-click event, how should I solve it? I also tried to unbind the click event when double-clicking.

But in this way, the click event cannot be used again. . .

Conflict handling sample code for click and double-click events_jquery

Later I asked others on the forum and finally got the answer. That is to use the setTimeout() method to set the time interval of the click event. This time interval is generally
set to 300ms. In this way, when double-clicking, since the time interval of double-clicking is less than 300ms, the click event will not be generated. Just generate the
dblclick event. In the double-click event, you need to use the clearTimeout() function to clear the processing of the click event. The code is as follows:
Copy code The code is as follows:

Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template