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

328
Views
jQuery para recorrer elementos con la misma clase

Tengo un montón de divs con el testimonial de la clase y quiero usar jquery para recorrerlos y verificar cada div si una condición específica es verdadera. Si es verdadero, debe realizar una acción.

¿Alguien sabe cómo haría esto?

over 4 years ago · Santiago Trujillo
3 answers
Answer question

0

Use cada uno: ' i ' es la posición en la matriz, obj es el objeto DOM que está iterando (también se puede acceder a través del envoltorio jQuery $(this) ).

 $('.testimonial').each(function(i, obj) { //test });

Consulte la referencia de API para obtener más información.

over 4 years ago · Santiago Trujillo Report

0

prueba esto...

 $('.testimonial').each(function(){ //if statement here // use $(this) to reference the current div in the loop //you can try something like... if(condition){ } });
over 4 years ago · Santiago Trujillo Report

0

Es bastante simple hacer esto sin jQuery en estos días.

Sin jQuery:

Simplemente seleccione los elementos y use el método .forEach() para iterar sobre ellos:

 const elements = document.querySelectorAll('.testimonial'); Array.from(elements).forEach((element, index) => { // conditional logic here.. access element });

En navegadores más antiguos:

 var testimonials = document.querySelectorAll('.testimonial'); Array.prototype.forEach.call(testimonials, function(element, index) { // conditional logic here.. access element });
over 4 years ago · Santiago Trujillo 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!