Home > Back-end >  Library: onElementReady to detect multiple elements existing at the same time
Library: onElementReady to detect multiple elements existing at the same time

Time:08-08

I saw this code: https://gist.github.com/sidneys/ee7a6b80315148ad1fb6847e72a22313

This is pretty nice, a way to detect changes inside a page.

Is there any way to make it detect defined elements and when all exist, execute a command?

Because no matter how many elements I define, it will trigger the function when one of them exists.

But I need to wait for all elements to appear, otherwise is it too early.

I want to achieve something like

onElementReady('element1 && element2 && element3', true, (el) => {
  console.log('All element1, element2, element3 exist!')
})

How can I make it trigger the function when multiple elements exist?!

  • Related