在jQuery中删除事件处理程序的最佳方法?

烈酒焚心 提交于 2020-08-09 11:19:05

问题:

I have an input type="image" . 我有一个input type="image" This acts like the cell notes in Microsoft Excel. 这就像Microsoft Excel中的单元格注释一样。 If someone enters a number into the text box that this input-image is paired with, I setup an event handler for the input-image . 如果有人在与该input-image配对的文本框中input-image ,我将为input-image设置一个事件处理程序。 Then when the user clicks the image , they get a little popup to add some notes to the data. 然后,当用户单击image ,他们会弹出一个弹出窗口以向数据添加一些注释。

My problem is that when a user enters a zero into the text box, I need to disable the input-image 's event handler. 我的问题是,当用户在文本框中输入零时,我需要禁用input-image的事件处理程序。 I have tried the following, but to no avail. 我尝试了以下方法,但无济于事。

$('#myimage').click(function { return false; });

解决方案:

参考一: https://stackoom.com/question/sNR/在jQuery中删除事件处理程序的最佳方法
参考二: https://oldbug.net/q/sNR/Best-way-to-remove-an-event-handler-in-jQuery
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!