jquery empty()方法将清除通过非jquery方式创建的事件侦听器 [英] Will jquery empty() method clear the event listeners created through non jquery means

查看:164
本文介绍了jquery empty()方法将清除通过非jquery方式创建的事件侦听器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含很多子元素的元素.我想清除此元素的内容,并用新结构替换它.

I have an element with a lot of child elements. I want to clear the content of this element and replace it with new structure.

为子元素分配了各种事件侦听器,并非所有这些侦听器都是通过jquery bind方法创建的.

The child elements are assigned with various event listeners and not all of those listeners are created through jquery bind method.

如果我使用jquery的empty方法清除该元素,它将删除所有事件侦听器还是仅清除通过jquery bind方法创建的侦听器?

If I use jquery's empty method to clear the element will it remove all the event listeners or will it clear only the listeners created through jquery bind method?

推荐答案

正如一些评论者所提到的,jQuery文档说empty()确实确实删除了事件处理程序:

As several commenters have mentioned, the jQuery docs say that empty() does indeed remove event handlers: http://api.jquery.com/empty/

发布此问题时可能不是这种情况,但是此页面是Google上的首个热门网站.

Perhaps that wasn't the case when this question was posted, but this page is the first hit on Google.

这篇关于jquery empty()方法将清除通过非jquery方式创建的事件侦听器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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