I often either add some HTML (for example, via insertAdjacentHTML
) or set the innerHTML
of some element. When this is done, I want to start a CSS transition by adding a class.
There seems to be no obvious way to determine how long I have to wait before doing this in order for the transition to work reliably.
Sometimes, a setTimeout(..., 0)
seems to be enough. Sometimes, not even a delay of 100 ms is enough.
Is there some kind of event that is triggered as soon as an element is... "ready"?