Jump to content

Double click instead of single click


bytesize

Recommended Posts

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>
Link to comment
https://forums.phpfreaks.com/topic/281757-double-click-instead-of-single-click/
Share on other sites

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.