1

リンクがクリックされたときに開いているパネルを右にスライドさせるために、次の JavaScript を使用しています。

jQuery(関数($) {

$('a.panel').click(function() {
    var $target = $($(this).attr('href')),
        $other = $target.siblings('.active'),
        animIn = function () {
            $target.addClass('active').show().css({
                left: -($target.width())
            }).animate({
                left: 0
            }, 500);
        };

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

});

また、すべてのパネルに閉じるボタンを追加したいと思います。クリックすると、パネルが閉じたり、左にスライドしたりします。

私はこのjsfiddleに取り組んでいます

アイデアはありますか?ありがとう。

4

1 に答える 1

2

どうぞ -

ワーキングデモ

$('.close').click(function(){        
        $(this).closest('.panel').animate({
                    left: -200
                }, 500);
    });
于 2012-10-16T11:44:48.473 に答える