源码网商城,靠谱的源码在线交易网站 我的订单 购物车 帮助

源码网商城

JQuery事件e参数的方法preventDefault()取消默认行为

  • 时间:2021-07-17 19:55 编辑: 来源: 阅读:
  • 扫一扫,手机访问
摘要:JQuery事件e参数的方法preventDefault()取消默认行为
JQuery事件的e参数的方法preventDefault()可以取消对象的默认行为。如下代码:
[u]复制代码[/u] 代码如下:
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <title></title> <script src="js/jquery-1.7.1.min.js"></script> <script type="text/javascript"> $(function () { $("a").click(function (e) { alert($(this).text()); e.preventDefault();//取消默认行为,没有这句话的话,会跳转到baidu网站上 }); }); </script> </head> <body> <a href="http://www.baidu.com">baidu</a> </body> </html>
  • 全部评论(0)
联系客服
客服电话:
400-000-3129
微信版

扫一扫进微信版
返回顶部