I want to trigger double click event on any element when a single click event occurs in that element.
To be more clear, let\'s say I have a text box with some text, and
The code you provided above works for me. A double click is triggered when a single click occurs. I used this variation:
var numd = 0;
$("#content").dblclick(function() {
numd++;
});
$("#content").click(function() {
$(this).dblclick();
});
numd
is incremented correctly.
For multiple clicks:
You could use a variable to keep track of which click you are on while using the click()
method to perform clicks. Here is an example to trigger a triple click.
var clicknum = 0;
$("#text-box").click(function() {
clicknum++;
if (clicknum < 3) {
$(this).click();
}
else {
// Reset clicknum since we're done.
clicknum = 0;
}
}