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

174
Views
Elemento indefinido de Javascript al agregar EventListener

Tener una clase:

 'use strict' class modal{ modal_wnd; close; constructor(){ this._init(); } _init(){ this.modal_wnd = document.getElementById('modal'); //div this.close = document.getElementById('mdl_close'); // span 'X' this.close.addEventListener('click', this.close_1); } show(){ this.modal_wnd.style.visibility = 'visible'; } close_1(){ alert(this.close); this.modal_wnd.style.visibility = 'hidden'; } }

Tenga el elemento div 'modal' y amplíe 'X' en él. En una página, tenga un botón para mostrar div:

 bt_modal.addEventListener("click", function(){ let mdl = new modal(); mdl.show(); });

eso funciona bien, pero cuando presiono 'X', aparece un error de este tipo: Error de tipo no detectado: no se pueden leer las propiedades de undefined (leyendo 'estilo') en HTMLSpanElement.close_1. ¿Alguien puede explicar por qué sucede?

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!