i am looking for a way to .preventDefault() to make a transition and then allow the default behavior
$('.withTrans').click(function(e){
e.preventDeault();
$(this).animate('opacity','0',300,function(){
e.resumeDefault(); // does something like this exist?
});
})
The preventDefault() method stops the default action of a selected element from happening by a user. This method does not accept any parameter and works in two ways: It prevents a link from following the URL so that the browser can't go another page. It prevents a submit button from submitting a form.
preventDefault = false; e. stopPropagatio = false; javascript.
The preventDefault stops the default browser behaviour when an event is fired like not redirecting the page on url click etc. The returnfalse also stops the default browser behaviour when an event is fired and does not let the event propagate. The callback execution is also stopped is returned immediately when called.
The preventDefault() method is used to prevent the browser from executing the default action of the selected element. It can prevent the user from processing the request by clicking the link.
$('.withTrans').click(function(event) {
if ( $(this).data("prevented") === true ) {
$(this).data("prevented", false);
return;
}
event.preventDefault();
$(this).animate('opacity', '0', 300, function() {
$(this).data("prevented", true).trigger("click");
});
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With