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

173
Vistas
El observador de mutaciones no funciona con elementos profundamente anidados.

Quiero observar un elemento profundamente anidado (área de texto en este ejemplo), pero el siguiente código no funciona.

¿Puede alguien ayudarme?

 <div id="parent" style="width:500px;height:200px;" class="parent mother"> </div> <button id="button" style="width:200px;height:60px;" class="button btn"></button> <script> button = document.getElementById("button"); const observer = new MutationObserver(function(mutations_list) { mutations_list.forEach(function(mutation) { mutation.addedNodes.forEach(function(added_node) { if (added_node.className == 's-JGcg fFOiLQ JhFYDw T9BsEA _01h2nw') { //if (added_node.id == 'child') { console.log(`${added_node}has been added`); observer.disconnect(); } }); }); }); observer.observe(document.querySelector("body"), { subtree: true, childList: true, }); button.addEventListener("click", fn); function fn() { document.querySelector("#parent").innerHTML = `<div><div><div> <textarea class="s-JGcg fFOiLQ JhFYDw T9BsEA _01h2nw" placeholder="What happens" rows="5"></textarea> </div></div></div>`; } </script>
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