是否有JavaScript / jQuery DOM更改侦听器? [英] Is there a JavaScript/jQuery DOM change listener?

查看:94
本文介绍了是否有JavaScript / jQuery DOM更改侦听器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

基本上,我希望在DIV的内容发生变化时执行脚本。由于脚本是分开的(在Chrome扩展和网页脚本中的内容脚本),我需要一种方式来简单地观察DOM状态的变化。我可以设置轮询,但似乎马虎。

解决方案

这个答案的旧内容现在是已弃用

查看其他答案基于 MutationObserver


Essentially I want to have a script execute when the contents of a DIV change. Since the scripts are separate (content script in chrome extension & webpage script), I need a way simply observe changes in DOM state. I could set up polling but that seems sloppy.

解决方案

The old contents of this answer is now deprecated.
See the other answers based on MutationObserver.

这篇关于是否有JavaScript / jQuery DOM更改侦听器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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