e.preventDefault()能否被撤销?
我正在寻找一种方法来.preventDefault()进行转换,然后允许默认行为
$('.withTrans').click(function(e){ e.preventDeault(); $(this).animate('opacity','0',300,function(){ e.resumeDefault(); // does something like this exist? }); })
$('.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"); }); });
假设您在动画完成后尝试关注链接:
$('.withTrans').click(function(e){ $(this).animate('opacity','0',300,function(){ window.location= this.href; }); return false; });
$('.withTrans').each(function(e){ $(this).unbind(); }