First of all, I'm sorry for my awful English.
I'm working on a code that allows you to detect single click, double click and triple. It works great, except the world this
. For some reason, it window
.
Here is my code:
$.fn.dblorone = function(single, dbl, triple){
var DELAY = 300,
clicks = 0,
timer = null,
clicked = "s",
i.on("click", function (e) {
clicks++; //count clicks
if (clicks === 1) {
clicked = "s";
setTimeout(function () {
if(clicked == "s"){
single();
clicks = 0;
}
}, DELAY);
} else if (clicks === 2) {
clicked = "d";
setTimeout(function () {
if(clicked == "d"){
dbl();
clicks = 0;
}
}, DELAY);
}else{
clicked = "t";
triple();
clicks = 0;
}
}).on("dblclick", function (e) {
e.preventDefault();
});
};
Here is a jFiddle: http://jsfiddle.net/9ab0g1o9/