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

262
Views
¿Equivalente a adjuntar un oyente a los botones en el documento listo en jQuery en lugar de Vanilla JavaScript?

¿Cómo convierto este código JavaScript en código jQuery?

 if (document.readyState == 'loading') { document.addEventListener('DOMContentLoaded', ready) } else { ready() } function ready() { var removeCartItemButtons = document.getElementsByClassName('btn-danger') for (var i = 0; i < removeCartItemButtons.length; i++) { var button = removeCartItemButtons[i] button.addEventListener('click', removeCartItem) } }
about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

La ejecución de algo cuando el documento está listo es manejada por el método $( document ).ready() .

getElementByClassName se puede reemplazar por un Selector de clase (".class")

Su ciclo for se puede eliminar porque con los métodos jQuery, todos se llaman en cada elemento devuelto.

addEventListener se puede reemplazar por .click() .

Entonces su código tiene solo tres líneas:

 $(function(){ $('.btn-danger').click(removeCartItem) })
about 4 years ago · Juan Pablo Isaza Report

0

jQuery es una biblioteca de Javascript y, por lo tanto, no es necesario convertir nada.

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!