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

256
Views
Reescriba Vanilla JS forEach en jQuery Each()

Estoy tratando de mantener mi código consistente ya que estoy usando jQuery para mi proyecto, sin embargo, estoy un poco confundido acerca del método each() de jQuery.

let cells=$(".cell").toArray();

mi código Vanilla JS está aquí:

 cells.forEach(function(cell,index){ cell.addEventListener('click',function(){ console.log(cell,index); }) })

mi jQuery está aquí:

 cells.each(function(index,cell){ cell.click(function(){ console.log(cell,index); }) })

Sé que el código es incorrecto, ya que la consola muestra Uncaught TypeError: cells.each is not a function pero revisé el documento jQuery, dice que each método es el método forEach en JS, ahora estoy realmente confundido.

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

0

$(".cell").each es una función. $(".cell").ToArray().each no es una función.

each método de jQuery existe en un objeto jQuery, no en matrices JS de vainilla.

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!