You can use following function in your webpage to use click and doubleClick using same button in jQuery. Normally if you use click and double click listener you will see only click is being initiated not double click.
$(document).ready(function () { var DELAY = 700, clicks = 0, timer = null; $(function () { $("#myButton").on("click", function (e) { clicks++; //count clicks if (clicks === 1) { timer = setTimeout(function () { // DO click operations clicks = 0; //after action performed, reset counter }, DELAY); } else { clearTimeout(timer); //prevent single-click action // DO double click operations clicks = 0; //after action performed, reset counter } }) .on("dblclick", function (e) { e.preventDefault(); //cancel system double-click event }); }); });
No comments On "Use click and doubleClick on same button using jQuery"
Post a Comment
Please try to write English. Don't use Bangla, Banglish etc. And if you post a comment in other languages then it may got deleted or ignored without notice.