$(document).ready(function() {
setTimeout("getTestimonial()", 10000);
});
function getTestimonial() {
var counter = $('#products #cart-widget .counter').html();
$('#products #cart-widget p > span').each(function(index) {
if($(this).is('.counter')) {
} else {
$(this).animate({opacity: 0}, 5000, function(){});
}
});
$.get("testimonials_include.php5", {'counter':counter}, function(data) {
$('#products #cart-widget p').replaceWith(data);
$('#products #cart-widget p').children().css("opacity",0);
$('#products #cart-widget p > span').each(function(index) {
if($(this).is('.counter')) {
} else {
$(this).animate({opacity: 1}, 5000, function(){});
}
});
});
setTimeout("getTestimonial()", 10000);
}
注意新元素的不透明度默认为1,所以在淡入可以工作之前,我必须将它们设置为0。有人知道为什么它不会消失吗?