如何监控DOM的变化? [英] How do I monitor the DOM for changes?

查看:133
本文介绍了如何监控DOM的变化?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法 - 使用jQuery或其他方式 - 监控DOM的插入,删除,样式更新等?

Is there a way - using jQuery or otherwise - to monitor the DOM for insertions, deletions, updates to styles, etc?

推荐答案

请参阅此处的MutationEvent元素:
https://developer.mozilla。 org / en / DOM / DOM_event_reference 但不推荐使用。

See "MutationEvent" elements in here: https://developer.mozilla.org/en/DOM/DOM_event_reference but those are deprecated.

jQuery现在提供了一种将事件附加到与选择器对应的现有AND future元素的方法:
http://docs.jquery.com/Events/live#typefn

jQuery now features a way to attach events to existing AND future elements corresponding to a selector: http://docs.jquery.com/Events/live#typefn

由于缺少正确的DOM节点修改信息,这可能是一个技巧。

It may be a trick you could use for lack of proper DOM Node modification info.

这篇关于如何监控DOM的变化?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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