It has always been considered that in web development, double-click Events are used sparingly and sparingly until the most recent project needs to tie an order on one button and double click on two events. At first, I thought it was just a two-button tie. Only later understand, is that I think too simple, double-click the event trigger will also trigger the click of the ~
After a study, finally using JS "settimeout" delay to execute the method, the click Delay of 300 milliseconds to solve the execution, the code is as follows:
Copy Code code as follows:
<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd "><title></title>
<mce:script src= "Jquery-1.6.min.js" mce_src= "Jquery-1.6.min.js" type= "Text/javascript" ></mce:script>
<mce:script type= "Text/javascript" >
<!--
$ (function () {
var num = 0;
var timefunname = null;
$ ("button"). Bind ("click", Function () {
To cancel a method that was not executed last time delay
Cleartimeout (Timefunname);
Delay 300 milliseconds to perform the click
Timefunname = settimeout (function () {
num++;
$ ("textarea"). Val ($ ("textarea"). Val () + "first" + num + "Minor event, event name: click/n");
}, 300); }. Bind ("DblClick", function () {
To cancel a method that was not executed last time delay
Cleartimeout (Timefunname);
num++;
$ ("textarea"). Val ($ ("textarea"). Val () + "first" + num + "Minor event, event name: Double-click/n");
});
});
--></mce:script>
<body>
<textarea rows= "cols=" ></textarea><button type= "button" > Submit </button></body>