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

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

He creado una función que reemplaza una cadena base64 con la dirección de correo electrónico correspondiente al hacer clic en algún texto.

Esto funciona, pero por alguna razón aparece este error: Uncaught TypeError: Cannot read properties of undefined (reading 'target') .

JS

 initEmails() { const emailToggles = document.querySelectorAll('.email'); if (!emailToggles) { return; } emailToggles.forEach(toggle => { toggle.addEventListener('click', this.replaceEmail); }); } replaceEmail(ev){ const target = ev.target.closest('.email'); if (!target.classList.contains('active')) { ev.preventDefault(); } const email = atob(target.dataset.value); target.setAttribute('href', 'mailto:' + email); target.querySelector('.replace').innerText = email; target.classList.add('active'); }

HTML:

 <span> <h5>@lang('E-mail')</h5> <a href="javascript:void(0);" data-value="{{ base64_encode($employee->email) }}" class="email"> <span class="replace">Toon e-mailadres</span> </a> </span>

Intenté verificar si existe .email antes de inicializar las funciones de esta manera:

 if (document.querySelector('.email') !== null) { this.initEmails(); this.replaceEmail(); }

Pero el error sigue apareciendo en mi consola.

¿Que puedo hacer para arreglarlo?

about 4 years ago · Juan Pablo Isaza
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!