I'm working on a function so that when an user clicks and holds onto a link, the link does not send the user to the appropriate link. However, the function that I used is not working. What I want is for the user to click on a link and if they hold it down for longer than one second, the link no longer works and no event is fired. After looking through it sometime, I can't find what's wrong with the code. So my question is, what did I do wrong? http://jsfiddle.net/rQP6g/2/
<a href="www.google.com" >link</a>
<script>
var timeoutId = 0;
$('a').mouseup(function() {
timeoutId = setTimeout(function(e) {
e.preventDefault();
e.stopPropagation();
}, 1000);
}).bind('mouseup', function() {
clearTimeout(timeoutId);
});
</script>