2

I want to perform action in javascript on detecting double click. Can you please let me know the same? This is a complex control combining label+ checkbox.

<td class=" odd" title="Double click to edit.">
<label class="cb_label_right">
<input id="check1_table#rowName#0" type="checkbox" data-ctrl="JSCtrl" disabled="">
<span>Row Name</span>
</label>

tablecell.ondblclick = function(){alert( "Double Clicked" );};

In the above line, if I click on label; double click is detected but not on checkbox

<input type="checkbox" disabled="disabled" />
<span>Fat Lock11</span>
<div style="position:absolute; left:0; right:0; top:0; bottom:0;">
</div>

The above code is working for sample code. I am new to Javascript, how to convert to Javascript as a single line

Venu
  • 353
  • 3
  • 6
  • 18

3 Answers3

2

$( "#check1").dblclick(function() {
  alert( "Double Clicked" );
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<input id="check1" type="checkbox" data-ctrl="JSCtrl">
Prabhat Sinha
  • 1,500
  • 20
  • 32
2

$('#check1').on('dblclick',function() {
  alert("Clicked");
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<input id="check1" type="checkbox" data-ctrl="JSCtrl">
ViKu
  • 235
  • 2
  • 14
-1

try

$( "#check1").bind("dblclick",function() {
   console.log("event occur");
});
Dhaval Pankhaniya
  • 1,996
  • 1
  • 15
  • 26
  • How is this any different from what ViKu's [answer](http://stackoverflow.com/a/36694600/369450) already said to do? – Uyghur Lives Matter Apr 18 '16 at 15:12
  • The above solutions are not working for my complex control. Any other suggestions please – Venu Apr 19 '16 at 08:58
  • can you please share fiddle ? – Dhaval Pankhaniya Apr 19 '16 at 09:01
  • I edited my query where adding div is helping my problem. But unfortunately it is working for one row only. If multiple rows are present then focus is shifting to last row and action corresponding to double click is performed on this last row. – Venu Apr 20 '16 at 10:19