我分叉了你的 jsfiddle 并尝试以我的方式进行修改:
http://jsfiddle.net/dharmavir/74KQc/
$(document).ready(function(){
var slides = $(".speaker").length;
$.each( $(".speaker"), function(index, node) {
$(node).data("rank", index+1);
});
$(".speaker").hide();
setInterval(slideRoller, 2000);
});
function slideRoller()
{
rollSlides("container", "slides", "speaker", 1, 5, 3);
}
function rollSlides(containerDisplay, containerParent, elmSetClass, startIndex, endIndex, displayLimit)
{
$("#"+containerDisplay).empty();
$.each( $("."+elmSetClass), function() {
var rank = $(this).data("rank");
if( rank <= displayLimit )
{
$(this).clone().show().appendTo("#"+containerDisplay);
}
else
{
$(this).hide().appendTo("#"+containerParent);
}
if( rank <= startIndex )
{
rank = endIndex;
}
else
{
rank = rank - 1;
}
$(this).data("rank", rank);
});
}