2

I have the following function which checks the ID on my image tag, detecting if the image itself is loaded onto the page. It works the first time when the page initially loads...

jQuery(function($) {    
    $('#imgLargeImageImage').bind('load', function() {
    console.log('new image loaded: ' + this.src);
    });
});

But how do I keep writing console.log for every time the image src attribute changes?

The image attribute changes dynamically when another java-script event is fired.

Thanks

klewis
  • 7,459
  • 15
  • 58
  • 102

1 Answers1

1

Even though it might not be supported by every browser check into DOMAttrModified. Here is a good post explaining the event - http://darcyclarke.me/development/detect-attribute-changes-with-jquery/ There is also some good info in this post - is there an alternative to DOMAttrModified that will work in webkit

Community
  • 1
  • 1
Jay Blanchard
  • 34,243
  • 16
  • 77
  • 119
  • Thank you Jay! But how would we implement DOMAttrModified into jQuery? I can't find one tutorial online that shows that. – klewis Dec 07 '12 at 19:39
  • The first post illustrates a jQuery plugin called watch which you can find here - http://darcyclarke.me/dev/watch/ – Jay Blanchard Dec 07 '12 at 20:03