English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

jQuery杂项

jQuery效果方法

jQueryevent.preventDefault()方法

event.preventDefault()方法可防止浏览器执行所选元素的默认操作。

  • 例如:

  • 阻止链接跟随URL

阻止提交按钮提交表单使用event.isDefaultPrevented()

方法检查事件是否调用了preventDefault()方法。

语法:

event.preventDefault()

实例

阻止链接打开URL:
  $("#submit").click(function(event){
event.preventDefault();
});

$("a").click(function(event){

示例
  $("#submit").click(function(event){
event.preventDefault();
});

测试看看‹/›

参数值参数
描述event事件

jQuery效果方法