Is there any way to determine if an element is being observed already?
if ( element /* is not being observed */ ) observer.observe(element)
There does not currently seem to be a way to detect if an element is being observed. To over come this the simplest solution is to add a flag to an element when you attach the Observer to it. Then you can look for this flag in the future when you need to check if it has already been added.
element.dataset.libraryNameObserverType = true
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With