EventListener to determine when data-src changes to src

Viewed 68

So I've been messing with a piece of code for some time now, and I can't seem to properly determine when data-src changes to src - So I want to see if I can hook a EventListener to an element and see if we can properly determine it then.

So let's say that I have the following element let iframe = videoWrapper.html(videoElement).children('iframe'); which gives me:
enter image description here

Which renders like this:
enter image description here

Please note: A third-party implementation changes the data-src to src dynamically based on various actions.

Question:
What is the best approach to take to check when the data-src has switched over to src and then execute conditionals/methods? I'd like to hook a event listener to determine that, but I don't know which one would be the right approach.

All help is appreciated!

1 Answers

MutationObserver The MutationObserver interface provides the ability to watch for changes being made to the DOM tree. It is designed as a replacement for the older Mutation Events feature, which was part of the DOM3 Events specification. Read more...

Related