문제

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?

도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top