触发事件对DOM属性的变化 [英] firing event on DOM attribute change

查看:101
本文介绍了触发事件对DOM属性的变化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法在属性更改时触发事件(可能是自定义的)?如果IMG src发生变化或者DIV的innerHtml,那么说吧?

解决方案

注意:截止2012年,Mutation Events已从标准中移除,现在已被弃用。有关如何使用替换的其他答案或文档,请 MutationObserver



你是指 DOM突变事件。对这些事件的浏览器支持不佳(但改善)。 jQuery的Mutation Events插件可能会让您有所作为。


is there any way to trigger event (may be custom) on attribute change?

Let's say, when IMG src is changed or DIV's innerHtml?

解决方案

Note: As of 2012, Mutation Events have been removed from the standard and are now deprecated. See other answers or documentation for how to use their replacement, MutationObserver.

You are referring to DOM Mutation Events. There is poor (but improving) browser support for these events. Mutation Events plugin for jQuery might get you some of the way.

这篇关于触发事件对DOM属性的变化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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