JQuery在单击相应的链接时向左和向右设置相邻div的动画

JQuery在单击相应的链接时向左和向右设置相邻div的动画,jquery,jquery-animate,slide,direction,Jquery,Jquery Animate,Slide,Direction,我这里有一把小提琴,来自堆栈溢出上的一个早期线程,它从左到右为所有div设置动画: Javascript jQuery(function($) { $('a.panel').click(function() { var $target = $($(this).attr('href')), $other = $target.siblings('.active'); if (!$target.hasClass('active')) { $other

我这里有一把小提琴,来自堆栈溢出上的一个早期线程,它从左到右为所有div设置动画:

Javascript

jQuery(function($) {

$('a.panel').click(function() {
    var $target = $($(this).attr('href')),
        $other = $target.siblings('.active');

    if (!$target.hasClass('active')) {
        $other.each(function(index, self) {
            var $this = $(this);
            $this.removeClass('active').animate({
                left: $this.width()
            }, 500);
        });

        $target.addClass('active').show().css({
            left: -($target.width())
        }).animate({
            left: 0
        }, 500);
    }
});
}))

我想通过单击3个div各自的链接来设置3个div的动画,以便:

  • 目标2应该是页面加载时的默认值(简单!)

  • 单击目标1的链接应始终从中滑入目标1 从左到右

  • 单击目标3的链接应始终从中滑入目标3 从右向左

  • 我试过了,但没有成功。请帮忙!:)-迪帕