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

698
Vistas
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 Respuestas
Responde la pregunta

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 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