jQuery:如何释放所有事件处理程序,dom更改? [英] Jquery: how to release all event handlers, dom changes?

查看:75
本文介绍了jQuery:如何释放所有事件处理程序,dom更改?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法重置当前页面?释放所有事件处理程序,以简单的方式删除Jquery切换的所有CSS,将页面恢复到原始状态而无需刷新?

Is there a way to reset the current page ? free all event handlers, remove any CSS toggled by Jquery, in simpler words, restoring the page to the original state without refreshing ?

推荐答案

refresh/reload page. There's no other way.我评论了OP的帖子.

refresh/reload page. There's no other way. I commented to the OP's post.

但是考虑到这一点,我认为有办法.

But thinking of it, I think there's a way.

在css部分上,正在对style属性进行动画处理.删除style属性将重置动画中的元素.但是请注意,如果您使用style属性来设置元素的样式,则该元素也会被删除.

On the css part, animations are being done on the style attribute. Removing style attribute reset the element from the animation. But take note that if you were using style attribute to style your element, that will be erased too.

在绑定事件上,您可能希望绑定命名空间事件.例如,绑定点击看起来像这样,

On the binding event, you may want to bind namespaced events. For example, binding click would look something like this,

$('#someID').bind('click.toBeRemove', function(){...})

所以删除事件就像$('*').unbind('.toBeRemove')一样容易.保留其他原始事件(在此示例中为click事件).

So that removing events would be easy as $('*').unbind('.toBeRemove'). Leaving the other original events (in this example the click event).

使用插件时,请使用具有.destroy()方法的插件,以删除其在元素上的功能和样式.

When using plugins, use those that has .destroy() method which removes it functionality and style on the element.

但这不是100%确定有效.只是一个理论而已. 是执行此操作的简便方法. - 是的!没有$(window).reset()可以重置页面而无需重新加载.

But this is not 100% sure working. Just a theory. There's NO easy way doing this. - Yes! there's no $(window).reset() that would reset the page without reloading.

这篇关于jQuery:如何释放所有事件处理程序,dom更改?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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