Why would this work :
$(document).on("dblclick", "#areaA tr:has(td)", function(e) { //code here });
and this does not
$("#areaA tr:has(td)").on('dblclick', function(e) { //Code here });
I'm following the example on the jquery documentation page exactly, but my double click does not fire. When I do it the first way, it works, but seems like it fires the event twice.
This is in the context of a Kendo UI grid.
Is there really a difference between these two pieces of code?
No it isn't. There is a dblclick event but no corresponding shortcut function.
The dblclick event fires when a pointing device button (such as a mouse's primary button) is double-clicked; that is, when it's rapidly clicked twice on a single element within a very short span of time.
dblclick(function(e){ e. preventDefault(); }); }); Above jQuery code will disable double click event for all the controls on the webpage.
The dblclick() method attaches an event handler function to an HTML element.
The main difference is that the condition in the first one will be checked each time you click. So if the element with id areaA
or the tr
or td
inside is added dynamically, only the first one can work.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With