bytesize Posted September 1, 2013 Share Posted September 1, 2013 If jquery 1.3 is used with this code a single click works, which is what I want, but if jquery 1.4 or higher is used a double click is required. Can anyone tell me what is causing the double click? <head> <style type="text/css"> .interactionLinksDiv a { font-size: 12px; font-family: Geneva, sans-serif; font-weight: normal; } .interactionLinksDiv a:hover { font-size:12px; text-decoration: underline; } .interactContainers { display:none; margin-top: 4px; } </style> <script type="text/javascript"> function toggleInteractContainers(x) { if ($('#'+x).is(":hidden")) { $('#'+x).slideDown(200); } else { $('#'+x).hide(); } $('.interactContainers').hide(); } </script> </head> <body> <?php $interactionBox = '<div class="interactionLinksDiv"> <a href="#" onclick="return false" onmousedown="toggleInteractContainers(\'add_friend\');">Add <b>Joey</b> to Friends</a> </div>'; echo $interactionBox; ?> <div class="interactContainers" id="add_friend"> Friend <b>Joey</b>? <a href="#" onclick="return false" onmousedown="toggleInteractContainers('add_friend');" title="Close">Later</a> </div> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/281757-double-click-instead-of-single-click/ Share on other sites More sharing options...
Irate Posted September 1, 2013 Share Posted September 1, 2013 Try using something like this... $.fn.req = $.fn.jquery.indexOf("1.3.") > -1 ? $.fn.click : ($fn.jquery.substr($.fn.jquery.indexOf("1.4."),$.fn.jquery.lastIndexOf(".")) >= "1.4" ? $.fn.dblclick : $.fn.click);If the jQuery version is 1.3 (or any version of 1.3), the $.fn.req property will be the normal click method of the jQuery object, otherwise, if the version is 1.4 or higher, it will be the dblclick function.So, to write code with the .req property, you'd do something like this. $(function(){ $('#clicked_element').req(function(e){ alert(e + " was fired."); }); });By the way, $.fn is the jQuery prototype object. Quote Link to comment https://forums.phpfreaks.com/topic/281757-double-click-instead-of-single-click/#findComment-1447713 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.