jQuery从元素中删除插件 [英] jquery remove plugin from element
问题描述
我有类似以下代码的内容:
I've got something similar to the following code:
$(a).click(function() {
$(element).plugin();
});
除了使用$($.plugin).remove()
之外,还有其他方法可以从某个元素中删除插件吗?不确定我的术语是否正确,但基本上我想将元素重置为其原始状态.
Is there a way to remove a plugin from an element other than using $($.plugin).remove()
? Not sure if I have the terminology correct but basically I want to reset the element to it's original state.
谢谢
推荐答案
您必须知道插件的作用才能逆转其效果.许多插件向DOM中添加了额外的元素,为元素添加了处理程序,等等.如果插件未创建任何额外的元素,则您可以简单地执行 unbind 所有事件处理程序,但这并不总是有效的.这将非常取决于所讨论的插件.
You'd have to know what the plugin does in order to reverse it's effects. Many plugins add extra elements to the DOM, handlers to elements, etc. If the plugin doesn't create any extra elements, you might be able to simply do a clone (without data and events) and replace or even just unbind all event handlers, but that's not always going to be effective. It would be very dependent on the plugin in question.
这篇关于jQuery从元素中删除插件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!