Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

139
Vistas
JavaScript mutation observer for multiple nodes

I have been coding this Chrome Extension for the past few weeks, and when I was almost done and everything was working, Bybit decided to change their HTML code and consequently my code stopped working. Now, what I want to do is that I need to observe a <div> element that contains 21 <div> elements. in those 21 elements, there are 3 or 4 spans and I need to access the second span. Below is my JS code:

function obser1() {
    const trades = document.querySelector("#root > main > div.main-left > div.react-grid-layout > div:nth-child(3) > div > div.by-card__body > div > div");
    tradescards.push(trades.childNodes);
    const observer = new MutationObserver(function (mutations) {
        mutations.forEach(function (mutation) {
            if (mutation.addedNodes.length) {

                console.log(trades);
                console.log(mutation.addedNodes);
    });
    observer.observe(trades, {
        childList: true,
        subtree: true,
        attributes: true,
        characterData: true
    })
}

Please keep in mind trades returns the parent div of the 21 divs.

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda