On the Web page, click the event that contains the Onmousedown,onmouseup,onclick process once. Similarly, the double-click event contains the Onmousedown,onmouseup,onclick,onmousedown,onmouseup,onclick,ondblclick process. Therefore, the onclick is also triggered when the ondblclick trigger is triggered on the Web page, so we need to distinguish them when we register the 2 events in the same element. The following uses delay processing to differentiate.
<script type= "Text/javascript" >
When we click, we want to only execute Clickalert
When we double-click, we want to only execute Dblclickalert
var timer;
$ (". Test"). On ("click", Function () {
Cleartimeout (timer);
Timer = SetTimeout ("Clickalert ()", 300); Processing that is clicked is delayed by 0.3 seconds
}). On ("DblClick", function () {
Cleartimeout (timer);
Dblclickalert ();
});
Click the thing you want to do
function Clickalert () {
Alert ("click Now");
}
Double-click the thing you want to do
function Dblclickalert () {
Alert ("Double-click now");
}
</script>
Use the time picker to differentiate between clicks and double clicks on a Web page