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 :(得分:0)
您应该使用setInterval
以及setTimeout
<强> 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);