Add The code for event is relatively simple. There are two methods:
Let’s talk about the double-click mechanism below:
timer in the click to delay the execution of the function. The complete code is as follows:
//绑定点击和双击事件 var _time = null; $(this).find("tr").dblclick(function(e){ clearTimeout(_time); console.log("dblclick"); //真正双击代码 }).click(function(e){ clearTimeout(_time); _time = setTimeout(function(){ console.log("click"); //单击事件在这里 }, 300); });
The above is the detailed content of An example of adding click and dblclick events at the same time in jQuery. For more information, please follow other related articles on the PHP Chinese website!