jquery preventDefault()方法 语法

假如想象 提交于 2019-12-06 04:44:29

jquery preventDefault()方法 语法

作用:preventDefault() 方法阻止元素发生默认的行为(例如,当点击提交按钮时阻止对表单的提交)。大理石平台价格

语法:event.preventDefault()

参数:

参数 描述
event     必需。规定阻止哪个事件的默认动作。这个 event 参数来自事件绑定函数。

jquery preventDefault()方法 示例

<html>
<head>
<script type="text/javascript" src="http://apps.bdimg.com/libs/jquery/2.1.1/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
  $("a").click(function(event){
    event.preventDefault();
  });
});
</script>
</head>
<body>
<a href="http://www.furuihua.cn/">大理石平台</a>
<p>preventDefault() 方法将防止上面的链接打开 URL。</p>
</body>
</html>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!