Question

I have several jQuery event listener on several links in a matrix (it's a map parcel selection). Now i already prevent the default action on mousedown, but if i prevent the action on mouseup, it doesn't work. I prevent the default action on mousedown on a link and start "marking" elements from there on. If a "mouseup" occurs in the same Element, the link get's executed.

So what i need to do is prevent link execution in mouseup, but it doesn't work.

$('a.parcel').on('mouseup',function(event){
    event.preventDefault();
});

This still executes the link that is given in the href of the a element.

Any Ideas anyone?

Was it helpful?

Solution

The default action you are preventing on the mouseup event is not responsible for changing the href. That being said, it doesn't matter if you prevent it or not, the href gets executed on the click event.

The click event gets fired after mousedown, so changing the mouseup to click should work just fine.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top