一个基本的例子:http: //jsfiddle.net/rNcNA/
HTML:
<div id="container">
<div class="content">Some content here</div>
<div class="content hidden">Other content here</div>
<div class="content hidden">Yet more content here</div>
</div>
JavaScript:
$(document).ready(function() {
var interval = 2000; // 2 seconds
var contents = $('#container').find('.content');
var index = 0;
var display = function(index) {
$('.content:visible').fadeOut('fast', function() { $(contents[index]).fadeIn(); });
index += 1;
if (index > contents.length-1) {
index = 0;
}
setTimeout(function() { display(index) }, interval);
}
display(index);
});