Home > Article > Web Front-end > Can jquery handle double-click and click events?
In jquery, double-click and click events can be handled through the dblclick() and click() methods. Use the dblclick() method to specify the function to run when a dblclick (double-click) event occurs; use the click() method to specify the function to run when a click (click) event occurs.
The operating environment of this tutorial: windows7 system, jquery1.10.2 version, Dell G3 computer.
jquery can handle double-click and click events.
The double-click event is a dblclick event, and the dblclick() method can be used to specify the function to be run when the dblclick event occurs; while the click event is a click event, and the click() method can be used to specify when the dblclick event occurs. Function that runs on click event.
jQuery Event - dblclick() method
The dblclick event occurs when an element is double-clicked.
A click occurs when the mouse pointer stays over an element, and then the left mouse button is pressed and released.
If two clicks occur within a short period of time, it is a double click event.
dblclick() method triggers the dblclick event, or specifies a function to run when the dblclick event occurs.
Tip: Problems may occur if dblclick and click events are applied to the same element.
Syntax: $(selector).dblclick(function)
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <script src="js/jquery-1.10.2.min.js"></script> <script type="text/javascript"> $(document).ready(function() { $("button").dblclick(function() { $("p").slideToggle(); }); }); </script> </head> <body> <p>这是一个段落。</p> <button>请双击此处</button> </body> </html>
jQuery event - click() method
When an element is clicked, the click event occurs . A click occurs when the mouse pointer stays over an element, and then the left mouse button is pressed and released. The click() method triggers a click event, or specifies a function to run when a click event occurs. Syntax:$(selector).click(function)
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <script src="js/jquery-1.10.2.min.js"></script> <script type="text/javascript"> $(document).ready(function() { $("button").click(function() { $("p").slideToggle(); }); }); </script> </head> <body> <p>这是一个段落。</p> <button>切换</button> </body> </html>
Related tutorial recommendations:
jQuery video tutorialThe above is the detailed content of Can jquery handle double-click and click events?. For more information, please follow other related articles on the PHP Chinese website!