2013-12-19 21 views
0
var arrNames = [ 
      '<span class="highlight">For All Joinery & Building Requirements.</span>', 
      '<span class="highlight">No Job Too Small, No VAT Charges, Free Estimates!</span>', 
      '<span class="highlight">Hardwood, Softwood & UPVC Windows, Doors, Porches & Conservatories.</span>', 
      '<span class="highlight">Extensions, UPVC Soffits & Facias, Roof & Renovation Work & Loft Conversions.</span>', 
      '<span class="highlight">Kitchens & Bathrooms designed & Installed with a full tiling service available.</span>', 
      '<span class="highlight">For your free quote, call us today!/span>', 
     ]; 

      $.each(arrNames, function(i, val) { 
       setTimeout(function() { 
        $('.quotes').fadeOut("slow", function() { 
         $(this).html(val).fadeIn("slow"); 
        }); 
       }, i * 8000); 

      }); 

我将如何重复此功能,以便它保持循环,它完美地播放它的一次。这个文本转换工作正常,但我需要连续循环

回答

0

你应该一起使用setIntervalsetTimeout

Working Fiddle

$.each(arrNames, function(i, val) { 
      setTimeout(function() { 
       $('.quotes').fadeOut("slow", function() { 
        $(this).html(val).fadeIn("slow"); 
       }); 
      }, i * 8000); 
     }); 
setInterval(function(){ 
$.each(arrNames, function(i, val) { 
      setTimeout(function() { 
       $('.quotes').fadeOut("slow", function() { 
        $(this).html(val).fadeIn("slow"); 
       }); 
      }, i * 8000); 
     }); 
},48000); 
+0

,只是让第一部分闪光! – Josh

+0

如果你可以创建小提琴会很好。 –

+0

http://jsfiddle.net/9eWQn/ – Josh

相关问题