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

707
Visualizações
MutationObserver.observe: Argument 1 is not an object

I wanna display a console message when a value of a span attribute (data-value) is changed. The span got no ID so I iterate each class out of it. But when I tried to run, it always displayed an error. Here is the HTML:

<span class="wpsl-selected-item" data-value="50"></span>

and here is the JS:

var target = document.querySelectorAll('.wpsl-selected-item');
for (var i = 0; i < target.length; i++) {
    create(target[i]);
}

var observer = new MutationObserver(function(mutations) {
mutations.forEach(function(mutation) {
    console.log('heya')
    });
});

  
var config = {
    attributes: true,
    attributeFilter: ['data-value']
};

observer.observe(target[i], config);

The error message is: Uncaught TypeError: MutationObserver.observe: Argument 1 is not an object. and I'm working on firefox

Any help would be very much appreciated, thank you!

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

does this work for you?

var target = document.querySelectorAll('.wpsl-selected-item');
if (target.length > 0) {
    var observer = new MutationObserver(function(mutations) {
        mutations.forEach(function(mutation) {
            console.log('heya')
        });
    });
  
    var config = {
        attributes: true,
        attributeFilter: ['data-value']
    };

    for(var i = 0; i < target.length; i++) {
        observer.observe(target[i], config);
    }
}
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