使用jQuery的click事件时出现错误 [英] Getting an error when using jQuery's click event

查看:189
本文介绍了使用jQuery的click事件时出现错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有.我正在使用jQuery向用于日历的某些按钮添加点击处理程序,但是上下文似乎并没有多大关系.我试图将任何东西(或什么都没有)放到click事件所调用的函数中.

there. I'm using jQuery to add a click handler to some buttons I'm using for a calendar, but the context doesn't seem to matter much. I've tried putting anything (or nothing) in the function that's called by the click event.

如果我连续几次单击按钮(三到四次),则会收到错误消息.它实际上似乎并没有影响函数本身的执行.显然,这只是引发一个与我有关的错误.

If I click the button a few (three or four) times in succession, I get an error. It doesn't actually seem to affect the execution of the function itself. It just throws an error, which concerns me, obviously.

有问题的代码如下:

$("#backward").click(function(event){. . .});

我得到的错误是:

Error in event handler for 'undefined': INDEX_SIZE_ERR: DOM Exception 1 Error: Index or size was negative, or greater than the allowed value.
at J (chrome-extension://mgijmajocgfcbeboacabfgobmjgjcoja/content_js_min.js:14:142)
at null.<anonymous> (chrome-extension://mgijmajocgfcbeboacabfgobmjgjcoja/content_js_min.js:17:184)
at chrome-extension://mgijmajocgfcbeboacabfgobmjgjcoja/content_js_min.js:1:182
at miscellaneous_bindings:286:9
at chrome.Event.dispatchToListener (event_bindings:379:21)
at chrome.Event.dispatch_ (event_bindings:365:27)
at chrome.Event.dispatch (event_bindings:385:17)
at Object.chromeHidden.Port.dispatchOnMessage (miscellaneous_bindings:253:22) event_bindings:369
chrome.Event.dispatch_ event_bindings:369
chrome.Event.dispatch event_bindings:385
chromeHidden.Port.dispatchOnMessage miscellaneous_bindings:253

很明显,问题在于扩展名,它只是 Google字典.

Obviously, the problem is with that extension, which is just Google Dictionary.

我不确定是我还是该问题,但我希望我的网站不要与Google词典冲突...

I'm not sure if the problem is with me or with that, but I'd prefer for my website not to clash with Google Dictionary...

谢谢!

推荐答案

如果与其他内容冲突,可以随时使用:

If it's clashing with something else you can always use:

$("#backward").click(function(e){
    e.preventDefault();
    . . .
});

这篇关于使用jQuery的click事件时出现错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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