jQuery 事件:检测对 div 的 html/文本的更改 [英] jQuery Event : Detect changes to the html/text of a div

查看:50
本文介绍了jQuery 事件:检测对 div 的 html/文本的更改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 div,它的内容一直在变化,无论是 ajax requestsjquery functionsblur 等等.

I have a div which has its content changing all the time , be it ajax requests, jquery functions, blur etc etc.

有没有一种方法可以在任何时间点检测到我的 div 上的任何变化?

Is there a way I can detect any changes on my div at any point in time ?

我不想使用任何间隔或检查的默认值.

I dont want to use any intervals or default value checked.

这样就可以了

$('mydiv').contentchanged() {
 alert('changed')
}

推荐答案

如果你不想使用计时器和检查innerHTML,你可以试试这个事件

If you don't want use timer and check innerHTML you can try this event

$('mydiv').on('DOMSubtreeModified', function(){
  console.log('changed');
});

更多细节和浏览器支持数据是这里.

More details and browser support datas are Here.

这篇关于jQuery 事件:检测对 div 的 html/文本的更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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