调用e.preventDefault()时,javascript错误"e"未定义

Chr*_*s22 2 javascript jquery object undefined preventdefault

我没有编写这段代码,而且我无法弄清楚为什么我在第一时间得到以下错误e.preventDefault().我已经尝试在.click事件处理程序中移动代码,传递给它function(e){},替换它return false,声明它var e = $(this.href)(不要笑,我正在努力学习),我已经检查了返回的值a href,它是返回正确的hash.视频播放,但是当我运行IE调试器时,我收到此错误.有人请告诉我如何正确调试和修复此问题.谢谢

在此输入图像描述

HTML

 <a href="#video1" class="blueBtn modal" style="width:150px;"><span>Watch Video <img width="10" height="17" src="images/bluebtn.png"></span></a></div>
Run Code Online (Sandbox Code Playgroud)

使用Javascript

// FANCY BOX
$("a.modal").click(function(){
    var inline=$(this).attr('href');
    $.fancybox({
        'transitionIn'      : 'none',
        'transitionOut'     : 'none',
        'href'              : inline,
        'onComplete'        : function(){
            $(inline+' .flowPlayer').videoPlayer();
            $.fancybox.center(true);
        },
        'onClosed'          : function(){loc();}
    });
    e.preventDefault();         
});

$(".print").click(function(e){
    window.open("print-docs/"+$(this).parent().attr('id')+".html","print","width=1,height=1");
    e.preventDefault();
});

function loc(){
    var location=window.location.href;
    var replaceHash=location.replace(document.location.hash,"");
    window.location.assign(replaceHash);
}
Run Code Online (Sandbox Code Playgroud)

rai*_*7ow 5

应该

$("a.modal").click(function(e) { // Note the "e" parameter
    // etc
});
Run Code Online (Sandbox Code Playgroud)

...相反,就像在第二次点击处理程序中一样.请参阅,这两个函数都是作为第一个参数提供的jQuery Event对象(本机Event对象的包装器).但您仍然必须让JavaScript知道您的函数中将引用此参数的确切方式.)