Jquery解除绑定的事件() [英] Jquery unbind events bound with one()

查看:89
本文介绍了Jquery解除绑定的事件()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法解除绑定一个()的事件绑定?排序像unone()

解决方案

从JQuery.com报价:



< blockquote>

您无法解除使用
.one()创建的监听器绑定。如果你想要解除绑定
的东西只有一次,但仍然可以在发生之前解除绑定,你必须
使用$ code> .bind()


类似于:

 code $ $(#element)。on(click,function(event){
// do stuff here
$(this).off(event);
}


Is there any method to unbind an event that has been bound with one()? Sort of like unone()

解决方案

Quote from JQuery.com:

You cannot unbind a listener created using .one(). If you want to be able to unbind something that has to occur only once but still be able to unbind it before it occurs, you have to use .bind()

Something like:

$("#element").on("click",function(event){
    //do stuff here
    $(this).off(event);
}

这篇关于Jquery解除绑定的事件()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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