can e.preventDefault() be reversed?

后端 未结 3 1863
旧巷少年郎
旧巷少年郎 2021-01-18 11:19

i am looking for a way to .preventDefault() to make a transition and then allow the default behavior

$(\'.withTrans\').click(function(e){
    e.preventDeault         


        
相关标签:
3条回答
  • 2021-01-18 11:45
    $('.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");
        });
    });
    
    0 讨论(0)
  • 2021-01-18 11:45

    assuming you are trying to follow a link after the animation is complete:

    $('.withTrans').click(function(e){
        $(this).animate('opacity','0',300,function(){
              window.location= this.href;
        });
        return false;
    });
    
    0 讨论(0)
  • 2021-01-18 11:47
    $('.withTrans').each(function(e){
        $(this).unbind();
    }
    
    0 讨论(0)
提交回复
热议问题