e.preventDefault-未定义e [英] e.preventDefault - e is not defined

查看:84
本文介绍了e.preventDefault-未定义e的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我有这个JS,当我运行代码时,我得到未定义e"-我想念什么?

So I have this JS and when i run the code i get "e is not defined" - What am I missing?

$('ul.result-filters > li a').click(toggleFilters());

function toggleFilters(e) {
   e.preventDefault();
   //do more stuff
}

推荐答案

使用此方法:

$('ul.result-filters > li a').click(toggleFilters);

您传递的是toggleFilters()的结果,而不是传递函数本身.

You were passing the result of toggleFilters() instead of passing the function itself.

这篇关于e.preventDefault-未定义e的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆