By default, the click event is triggered when a double-click event occurs, but sometimes this is not what we want. So how can we block the triggering of the click event when double-clicking? There is a method of delaying execution circulating on the Internet. The general idea is as follows:
1. Declare a global timer variable such as: clickTimer
2. Set a timer in the agent click event. The real click event processing is triggered after 220 milliseconds by default. Function
3. Judge the timer variable in the double-click event. If the variable is not NULL, it means that the click event was triggered before the double-click event was triggered. Cancel the timer because the real click event processing function is after 220 milliseconds. will be triggered, so if the timer ends at this time, the actual click event processing function will not be executed.
Attached code:
1var timerClick=null;
2//Click event proxy
3function _onNodeClick(id){
4 //onNodeClick is the real click event processing function
5 timerClick=window.setTimeout(" onNodeClick('"+id+"')",220);
6 }
7//Double-click event handling function
8function _onNodeDbClick(id){
9 if(timerClick){
10 window.clearTimeout(timerClick);
11 }
12}
The above is the content of delaying triggering to prevent onDbClick from triggering the onClick event. For more related content, please pay attention to the PHP Chinese website (m.sbmmt.com)