The answer is in the tags. You have capture the mousedown
and mouseup
events.
- First catch the
mousedown
event and store the state. - Next catch the
mouseup
event and compare the coordinates of with themousedown
state. - If the mouse has moved significantly between events, don't process the click.
Replace the above script section as follows:
<script>
$(document).ready(function() {
var lastMouseDownEvent = null;
// capture your last "mousedown" event and store it
$(".row").mousedown(function(event) {
console.log(event); // lets see the data in your Developer Mode log
lastMouseDownEvent = event;
});
// catch the "mouseup" event and compare the distance from "mousedown"
$(".row").mouseup(function(event) {
console.log(event);
var href = $(this).find("td").html();
switch(event.which) {
case 1: // left click
// only process left click if mousedown and mouseup occur at the same location on screen.
// NOTE: for my mom's shaky hand I added the 5 pixel allowance.
if (Math.abs(event.clientX-lastMouseDownEvent.clientX) < 5 &&
Math.abs(event.clientY-lastMouseDownEvent.clientY < 5))
window.location.href = href;
break;
}
lastMouseDownEvent = null;
});
});
</script>