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

110
Vistas
Specify which element triggered MutationObserver on multiple elements

With the help of the following SO-post. I know it is possible to track multiple elements with a single MutationObserver-object. I want to track the text of two elements on a website, so I write the following script:

var seconds = document.getElementsByClassName('sr-lmt-0-ms-countdown__time srt-primary-7 srm-large')[2];
var minutes = document.getElementsByClassName('sr-lmt-0-ms-countdown__time srt-primary-7 srm-large')[3];


var callback = function(mutations) {
    for (var mutation of mutations) {
            // do something
            // console.log(mutation + (minutes or seconds));
        }
    };

var observer = new MutationObserver(callback);
var config = {characterData: true, subtree: true};

observer.observe(minutes, config);
observer.observe(seconds, config);

How can I alter this script so the Console shows which variable triggered the MutationObserver?

Edit

If I inspect mutation.target I see the following:

enter image description here

I don't see whether sec or minutes triggered the mutation? How can I make this distinguishing?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

let observer = new MutationObserver(mutationRecords => {
  console.log(mutationRecords); // console.log(the changes)
});

about 4 years ago · Juan Pablo Isaza Denunciar
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