Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

112
Visualizações
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 Respostas
Responde à pergunta

0

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

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda