Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

235
Views
TypeError no capturado: no se pueden leer las propiedades de undefined (leyendo 'parentNode')

He agregado el siguiente script a mi página web donde puede ocurrir una acción de suscripción al boletín. Estoy tratando de mostrar contenido personalizado una vez que el usuario se suscribe.

 <script> function insertAfter(referenceNode, newNode) { referenceNode.parentNode.insertBefore(newNode, referenceNode.nextSibling); } var news = document.getElementsByClassName("et_pb_newsletter_success")[0].selectedIndex; var text = document.createTextNode("Thank you for joining our SOS Family! We are very grateful to have you with us. Thanks to compassionate people like you, SOS is meeting needs and improving the lives of our friends and neighbours in District 69. You can expect valuable emails from us on a regular basis, and you can unsubscribe at any time."); var learn = document.createTextNode("Learn more about SOS.") insertAfter(news,text); insertAfter(text,learn); var img = document.createElement("img"); img.src = "https://sosd69.com/wp-content/uploads/newsletter_success.jpeg"; insertAfter(learn,img); let btn = document.createElement("button"); btn.innerHTML = "Watch Video"; btn.onclick = function () { window.location='https://www.youtube.com/watch?v=OcYyhazCiHs'; }; btn.classList.add("et_pb_button_0"); insertAfter(img,btn); </script>

Recibo el siguiente error de consola:

 Uncaught TypeError: Cannot read properties of undefined (reading 'parentNode') at insertAfter ((index):666) at (index):672

¿Hay algún error en la forma en que he creado la función insertAfter? Quizás el problema es que el script se está cargando antes de que se cree la clase "et_pb_newsletter_success", cuando se hace clic en el botón de suscripción. ¡Cualquier idea sería muy apreciada!

about 4 years ago · Santiago Gelvez
1 answers
Answer question

0

getElementsByClassName: proporciona una matriz, por lo que debe obtener los elementos de esa matriz y usarlos.

 var news = document.getElementsByClassName("et_pb_newsletter_success")[0];
about 4 years ago · Santiago Gelvez Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!