最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - jQuery - Event for when an attribute of a node changes - Stack Overflow

programmeradmin0浏览0评论

I have a webpage with an external javascript library, and my own extra code. The external library can't be change. It manipulates dom elements, adds new ones, changes attributes (e.g. src on some <img> nodes, etc.). I am using jQuery. Is there any event handler that is fired when the value of an attribute changes of a node?

i.e. is there anyway I can detect (in jQuery) when the src of an <img> is changed (by someone else?)

I have a webpage with an external javascript library, and my own extra code. The external library can't be change. It manipulates dom elements, adds new ones, changes attributes (e.g. src on some <img> nodes, etc.). I am using jQuery. Is there any event handler that is fired when the value of an attribute changes of a node?

i.e. is there anyway I can detect (in jQuery) when the src of an <img> is changed (by someone else?)

Share Improve this question asked Nov 14, 2010 at 21:15 AmandasaurusAmandasaurus 60.8k74 gold badges193 silver badges255 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 3

You can go for the jQuery watch plugin to detect changes in the attributes.

Check out this post too:

http://darcyclarke.me/development/detect-attribute-changes-with-jquery/

If you just need to know when the source of an image changes, you just need to add an onload handler to the image. When the image loads, it will fire the event.

$("img").load( function(){ alert('loaded'); } );
发布评论

评论列表(0)

  1. 暂无评论