Home > Web Front-end > JS Tutorial > body text

JS realizes the coexistence of mouse click and double-click events_javascript skills

WBOY
Release: 2016-05-16 16:56:18
Original
1490 people have browsed it

I have always thought that in web development, double-click events are rarely used. Until recently, the project required binding two events, click and double-click, on a button. At first I thought it was just two events tied to the button... but later I realized that I was thinking too simply. When the double-click event is triggered, the click will also be triggered at the same time~囧

After some research, I finally solved the problem by using the "setTimeout" delayed execution method in JS to delay the click execution for 300 milliseconds. The code is as follows:

Copy code The code is as follows:

 

< /mce:script>                                                       var timeFunName = null;                                                                    
// Delayed 300 millisecond execution. Click
Timefunname = Settimeout (function () {
Num;
$ ("textarea"). Val ($ ("textarea"). num "events, event name: click/n");                                                                                                                                                                                                                                                              
clearTimeout(timeFunName);  );                  
}); textarea rows="20" cols="50">


Related labels:
js
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template