Javascript 使用jquery防止默认行为

Javascript 使用jquery防止默认行为,javascript,jquery,Javascript,Jquery,嗨,我有一个锚标记,但我想防止使用jquery的默认行为。但是没有得到确切的答案。你能告诉我我的密码有什么问题吗 $(document).ready(function(){ $("a[name]").click(function(event){ alert("As you can see, the link no longer took you to jquery.com"); eventpreventDefault(); }); }); $(文档).ready

嗨,我有一个锚标记,但我想防止使用jquery的默认行为。但是没有得到确切的答案。你能告诉我我的密码有什么问题吗

$(document).ready(function(){ $("a[name]").click(function(event){ alert("As you can see, the link no longer took you to jquery.com"); eventpreventDefault(); }); }); $(文档).ready(函数(){ $(“a[名称]”)。单击(函数(事件){ 警报(“正如你所看到的,这个链接不再把你带到jquery.com”); eventpreventDefault(); }); }); 您缺少一个点:

eventpreventDefault();
应该是:

event.preventDefault();
如果希望禁用默认操作(转到指定链接)以及事件冒泡,也可以使用
return false

$(document).ready(function(){
   $("a[name]").click(function(event){
     alert("As you can see, the link no longer took you to jquery.com");
     return false;
   });
});
您缺少一个点:

eventpreventDefault();
应该是:

event.preventDefault();
如果希望禁用默认操作(转到指定链接)以及事件冒泡,也可以使用
return false

$(document).ready(function(){
   $("a[name]").click(function(event){
     alert("As you can see, the link no longer took you to jquery.com");
     return false;
   });
});