jquery preventDefault()方法 语法

时间:2019-11-30 16:53:45   收藏:0   阅读:84

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>

原文:https://www.cnblogs.com/furuihua/p/11962503.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!