阻止默认行为-event.preventDefault();

Posted jinsuo

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了阻止默认行为-event.preventDefault();相关的知识,希望对你有一定的参考价值。

<html>
<head>
<script type="text/javascript" src="/jquery/jquery.js"></script>
<script type="text/javascript">
$(document).ready(function(){
  $("a").click(function(event){
    event.preventDefault();
  });
});
</script>
</head>
<body>
<a href="http://w3school.com.cn/">W3School</a>
<p>preventDefault() 方法将防止上面的链接打开 URL。</p>
</body>
</html>
//阻止默认行为

 

以上是关于阻止默认行为-event.preventDefault();的主要内容,如果未能解决你的问题,请参考以下文章