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

99
Views
¿Por qué este controlador de eventos de un bucle de clase no responde?

Estoy recorriendo 10 divs con la misma clase para agregar controladores de eventos que deberían cambiar el borde con un clic del mouse. Estoy usando getElementsByClassName. No hay respuesta al clic en ninguno de los divs. La función simple funcionó en otro div en un controlador de eventos.

el html:

 <div class="note-small"> <p>blah</p> </div>

Usé este JS de vainilla:

 const note_small_class = document.getElementsByClassName('note-small'); for (let i=0; i < note_small_class.length; i++) { note_small_class[i].addEventListener('click', () => { highlightNote(note_small_class[i]); }) }; function highlightNote(note) { note.style.background.color = 'red'; };

note_small_class se muestra como un objeto (colección HTML) en la consola. Algo no funciona, agradecería cualquier ayuda. Gracias.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

note.style.background.color = 'red';

Parece que hay un problema con lo que está configurando para que sea el estilo, la propiedad debe ser backgroundColor , no background.color , intente esto:

 note.style.backgroundColor = 'red';
about 4 years ago · Juan Pablo Isaza 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!