0

好的,所以我有这个代码,它几乎可以工作我只是停留在最后一点!

$('.button').click(function() {
var id = this.id;
$('#slide'+id+'').each(function() {
    if ($(this).offset().left < 0) {

    } else {
        $('.current').animate({ left: '-200%', }, 1500 );
        $('.current').removeClass("current").addClass("previous");

        $(this).animate({ left: '-100%', }, 1500 );
        $(this).addClass("current");
        $('.previous').removeAttr('style');

    }
});
});

如您所见,当前幻灯片向左移动,新幻灯片从右侧移入。然后将当前幻灯片重新分类为以前的幻灯片,然后将新幻灯片分类为当前幻灯片。

然而,新的上一张幻灯片仍然具有内联样式 left:-100% 应用于它。我需要删除这种风格!??

基本上我需要幻灯片总是从右到左,即使它已经被访问过!请有人帮忙!??

http://jsfiddle.net/ngpsk/

** * ** * **自己解决了* ** * ***

$('.button').click(function() {
var id = this.id;
$('#slide'+id+'').each(function() {
    if ($(this).offset().left < 0) {

    } else {
        $('.current').animate({ left: '-100%', }, 2000, function()
                {
                    $(this).removeAttr('style').removeClass("current");
                    $('#slide1').css("left", "100%");
                }
            );

        $(this).animate({ left: '0%', }, 2000 );
        $(this).addClass("current");
    }
});

});

似乎至少可以工作!

4

1 回答 1

0

动画完成后删除类,例如: jQuery 事件顺序和等待动画完成

于 2013-05-23T11:27:32.417 回答