Home >Web Front-end >JS Tutorial >jQuery prevents click double-click from multiple submissions and passing dynamic functions or multiple parameters_jquery

jQuery prevents click double-click from multiple submissions and passing dynamic functions or multiple parameters_jquery

WBOY
WBOYOriginal
2016-05-16 16:53:411152browse

Today I am writing about the problem of JQ's double-click event preventing multiple submissions, and it can be defined in batches through functions, which makes it more versatile and dynamically binds elements' events through methods. And you can dynamically pass function names or multiple parameters (this example only passes the function name and call it through Eval).

We all know that in jQuery's event binding, two click events (click) can be triggered when executing a double-click event (dblclick). That is, a label element (such as div, etc.), if the element is bound to both a click event (click) and a double-click event (dblclick), then when the click event (click) is executed, the double-click event (dblclick) will not be triggered, and the double-click event will not be triggered. event (dblclick) will trigger two click events (click).

First look at the execution sequence of click events:

Click (click): mousedown, mouseout, click;
Double-click (dblclick): mousedown, mouseout, click, mousedown, mouseout , click, dblclick;

In the double-click event (dblclick), among the two click events (click) triggered, the first click event (click) will be blocked, but the second one will not meeting. That is to say, the double-click event (dblclick) will return the result of a click event (click) and the result of a double-click event (dblclick). Instead of the result of a double-click event (dblclick) and the result of two click events (click).

In this case, just eliminate the extra click event (click) and the problem will be solved.

The effect is as follows:
http://images.cnitblog.com/i/554071/201404/010846579687197.png
The source code is as follows:

Copy code The code is as follows:





jQuery prevents click double-click from being executed and delivered multiple times Dynamic function method




Show test results:

Click me






Statement:
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