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

81
Views
¿Cómo hacer una animación infinita de jquery?

Estoy tratando de implementar una función jQuery con un bucle infinito para animar el fondo del cuerpo con 3 colores. No puedo pensar en una solución agradable y limpia. ¿Algo como esto?

 $(document).ready(function(){ $('body').animate({backgroundColor:'#ffcc00'}, 500, function(){ $('body').animate({backgroundColor:'#eeeeee'}, 500, function(){ $('body').animate({backgroundColor:'#3b5998'}, 500); }); }); });

¿Alguna idea?

over 4 years ago · Santiago Trujillo
3 answers
Answer question

0

$(document).ready(function(){ function animate() { $('body').animate({backgroundColor:'#ffcc00'}, 500, function(){ $('body').animate({backgroundColor:'#eeeeee'}, 500, function(){ $('body').animate({backgroundColor:'#3b5998'}, 500, function(){ animate(); }); }); }); } animate(); });
over 4 years ago · Santiago Trujillo Report

0

Puedes eliminar el anidamiento, pero la solución es un poco más gorda:

 var cols = "#ffcc00,#eeeeee,#3b5998".split(",") var cPos = 0 $(document).ready(function() { swapC() } function swapC() { $('body').animate({ backgroundColor:cols[cPos] }, 500) cPos++ if (cPos == cols.length) { cPos = 0 } window.setTimeout(function() { swapC() }, 500) }
over 4 years ago · Santiago Trujillo Report

0

$(document).ready(function(){ colors = ['#FFB30C', '#58EC00', '#0087EC', '#EEEEEE', '#FF5A00' ] var i = 0; animate_loop = function() { $('body').animate({backgroundColor:colors[(i++)%colors.length] }, 500, function(){ animate_loop(); }); } animate_loop(); });

Demostración: http://jsfiddle.net/bHEVr/

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!