.dblclick() is a shorthand for binding or triggering the dblclick event. With a handler it binds; with no arguments it triggers. Prefer .on / .trigger in new code.
Syntax
Start with these common calls. Keep them short and readable.
.dblclick() with no arguments fires the event — prefer .trigger("dblclick").
jQuery
$("#target").dblclick(function () {
console.log("Handler for dblclick called.");
});
$("#fire").click(function () {
$("#target").dblclick(); // same idea as .trigger("dblclick")
});
With a handler — .dblclick(handler) or .dblclick(eventData, handler) — it binds a double-click callback. With no arguments — .dblclick() — it triggers dblclick on each matched element. The binding forms are deprecated since jQuery 3.3.
Yes. Prefer .on("dblclick", handler) or .on("dblclick", eventData, handler) to bind, and .trigger("dblclick") to fire. jQuery 3.x still runs .dblclick() for compatibility.
.dblclick(handler) only registers a callback. .dblclick() with no arguments triggers the event (same idea as .trigger("dblclick")).
Replace .dblclick(fn) with .on("dblclick", fn). Replace .dblclick(data, fn) with .on("dblclick", data, fn). Replace no-arg .dblclick() with .trigger("dblclick").
Yes for legacy code. It still works, but new code should use .on / .trigger. See the dblclick event tutorial for the modern API.
Since 1.4.3 you can pass data before the handler. It appears as event.data inside the callback. Modern form: .on("dblclick", eventData, handler).