javascript - PreventDefault 在 Firefox 中不生效

标签 javascript jquery html

我有一个名为 shop_cat_edit 的输入,代码如下。但在 FireFox 中,这段代码永远不会工作...甚至 IE 也觉得没问题。我做错了什么?

$('[name=shop_cat_edit]').on('click',function(e){
   $('#shop_cat_selector_form').on('submit', function(){e.preventDefault();}); 
});

最佳答案

变量e未在您使用它的函数中声明

function(){             <-- no function param for event is set here
  e.preventDefault();
}

它应该看起来像这样

  function(e){e.preventDefault();}

关于javascript - PreventDefault 在 Firefox 中不生效,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36382606/

相关文章:

javascript - AngularJS 不会编译 script 标签内的表达式

javascript - Angular JS : Binding using ng-model with an ng-repeat on a select element

javascript - CSS 转换不适用于 Firefox

html - 为什么仅使用语义 UI 中的网格模块时我的列太宽?

javascript - 使用 jQuery 更改 h- 文本

html - 悬停跨度显示在图像下方

javascript - 如何在通过域名进入时只显示一次页面预加载器?

javascript - knockout JS : Creating Json from viewmodel observable array

javascript - jQuery 在 div 元素内部和外部分离 dblclick 事件

javascript - 在 jQuery 循环中定位相同选择器的更快方法