E.preventDefault - is there a doDefault method?

let's say I have a link:

<a href='http://example.com/file.zip' id='dl'>Download</a> 

And while someone clicks on it, I want to do something, for example:

 $("#dl").live("click", function(e){ e.preventDefault(); $("#dlbox").fadeOut(500); }); 

Is there any way after I e.preventDefault to continue and do Default? something like

 $("#dl").live("click", function(e){ e.preventDefault(); $("#dlbox").fadeOut(500); e.doDefault(); }); 

so that it fires the event normally?

+7
source share
3 answers

You can only prevent the default behavior (using e.preventDefault() ).

Now, if you expect the link to be wrapped when the .fadeOut () method is finished, you should prevent the default behavior and use the fadeOut method callback parameter to navigate when the animation finishes:

 $("#dl").live("click", function(e){ e.preventDefault(); var href = this.href; $("#dlbox").fadeOut(500, function() { window.location = href; }); }); 

Demo

+8
source

There is no doDefault () command, you need to reverse engineer your code.

I would prevent default and then execute the url directly through window.location . It is also possible to use another tag for the anchor tag - redefining its functionality, it makes no sense to use it in the first place.

for example, something like this:

 $("#dl").live("click", function(e){ e.preventDefault(); $("#dlbox").fadeOut(500, function() { window.location='www.fish.com'; }); }); 
+2
source

Maybe this post can help you? You can also just return false so that the link does not get to the location in href.

0
source

All Articles