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

333
Views
Hacer un carrusel (JS) usando datos de una API de búsqueda

Estoy tratando de hacer un carrusel automático usando los datos de una API. No sabré cuántos elementos hay para mostrar, ya que eso dependerá de la búsqueda del usuario. Hasta ahora he logrado crear una página que hojea la información cada 5 segundos, pero ¿hay alguna manera de crear un efecto que muestre los datos antiguos deslizándose hacia un lado mientras que los datos nuevos se deslizan desde el otro lado?

Aquí está mi código:

 document.querySelector('button').addEventListener('click', findDrink) let counter = 0 function findDrink() { let drinkName = document.querySelector('input').value; fetch(`https://thecocktaildb.com/api/json/v1/1/search.php?s=${drinkName}`) .then(data => data.json()) .then(item => { document.querySelector('h2').innerText = item.drinks[counter].strDrink; document.querySelector('img').src = item.drinks[counter].strDrinkThumb; document.querySelector('h3').innerText = item.drinks[counter].strInstructions; let length = item.drinks.length if (counter > length - 2) { counter = 0; } else { counter += 1 } }) } setInterval(findDrink, 5000)
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!