javascript - Double click event for a select tag. issue with Firefox -
i have select element , need event fire when double click on it. here html code
<select class='my_field' unselectable='on' onselectstart='return false;' onmousedown='return false;'> <option value="test">test</option> </select>
and here javascript code
$( document ).ready(function() { $(".my_field").dblclick(function(e) { alert('double click'); }); });
in browsers ie or chrome event works ok. but not in firefox.
i prepared jsfiddle. in jsfiddle have added text input show event works fields other select tag, even in ff.
i'm not sure if dblclick standard event.
but can implement few more code (not tested):
$(document).ready(function(){ (function(){ // closure. not needed if code. var dblclickms = 1000; // 1 second. adjust @ needings. var fld = $(".my_field"); var t0 = 0; fld.on("click", function(){ var t = (new date()).gettime(); if (t - t0 <= dblclickms) { alert('double click'); } else { t0 = t; }; }); })(); });
Comments
Post a Comment