0

I am working on a Cordova app using jquery. I want to hide a div when it is double clicked. I get an alert using the single click code below

$(document).on('click', '#dynamicDiv', function() {
   alert("click");
});

But I do not get a response with the double click code

$(document).on('dblclick', '#dynamicDiv', function() {
    alert("double click");
});

Any ideas why this could be?

10 Rep
  • 2,217
  • 7
  • 19
  • 33
CJ Broersma
  • 179
  • 1
  • 11
  • 1
    Please provide a [mcve]. It [works fine](https://jsfiddle.net/p7vhtuaj/) for me. – Unmitigated Aug 11 '20 at 00:33
  • @hev1 It doesn't work if you also have a `click` handler. https://jsfiddle.net/barmar/uzL28s4t/ – Barmar Aug 11 '20 at 00:41
  • It has nothing to do with whether the DIV is dynamic. If you have a click and double click handler, only the click handler runs. The same problem happens without event delegation: https://jsfiddle.net/barmar/uzL28s4t/4/ – Barmar Aug 11 '20 at 00:45
  • @hev1 I'm confused. I see that the double click is working for you, but for me, when the div is dynamically created it does not work. The puzzling part is that if I change it to a single click it works. Thats why I was wondering if it is different when div is dynamic. – CJ Broersma Aug 11 '20 at 14:56

1 Answers1

0

dblclick is for mouse event desktop, may be you can refer to this answer jQuery on 'double click' event (dblclick for mobile)

Cheong BC
  • 306
  • 1
  • 7