jQuery从元素中删除单击事件处理程序 [英] jQuery remove click event handler from an element

查看:191
本文介绍了jQuery从元素中删除单击事件处理程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这个事件处理程序,

I have this event handler,

$('#table_product').on 'click', '.th1',(event) ->
       $(this).unbind("click") #Not working

m尝试实现是当用户触发此事件时,它将从 .th1 中禁用/分离单击事件处理程序。

What I'm trying to achieve is when a user triggers this event, it will disable/detach the click event handler from .th1. So it won't give any response to the user for the next request.

目前,我尝试过 unbind()

Currently, I have tried unbind() and off(), but still no luck.. Any other suggestion ?

推荐答案

首先,如果你给我们更多的代码,我们可以很容易地测试代码。

First, it could be useful if you give us more code, so we can test the code easily.

API 的jQuery:

$("#table_product").click(function() {

}

根据 SO 的另一个问题的答案:

And from the answer of another question on SO:

$('.th1').off('click');

也许这会有帮助吗?

这篇关于jQuery从元素中删除单击事件处理程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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