0

我试图让这些 div 在单击箭头时淡出(就像一个非常简单的幻灯片)。我可以让它们一个一个地淡出,就像这样:

$(document).ready(function(){
    $('li').click(function(){
        $(this).fadeOut();
    });
});

JSFIDDLE

然而,这不会让我

  • 循环(所以当所有都淡出时重新开始)
  • 单击另一个类时它将不起作用

是否有一个 jQuery 方法可以遍历每个<li>和淡出。如果是最后一个li,是否重新开始序列?

4

1 回答 1

3

这是你需要的吗?http://jsfiddle.net/x3buT/39/

在这里我淡出第一张幻灯片,然后将其移到行尾并淡入下一张

$(document).ready(function(){
    $('.slide:not(:first)').hide();
    //If you only need to change with the arrow, remove .slide from next line
    $('.slide,.arrow').click(function(){
        $('.slide').first().fadeOut(function(){
            $(this).next().fadeIn();
            $(this).appendTo('.inner');
        });
        return false;
    });
});
于 2013-07-25T19:14:30.597 回答