Adrien Castagliola Adrien Castagliola - 3 months ago 23
Javascript Question

Is there an event to detect if an attribute is set in Javascript?

I want to execute a script when some data attribute are set. Attributes can be set AFTER the all page is loaded.

In that case the script doesn't execute.

<div data-id='' data-position=''></div>

But in that one, i want to execute it

<div data-id='3' data-position='67'></div>

Is it even possible ?


You can use MutationObserver to listen attribute change and act upon.