用于扩展细节问题的jQuery动画

时间:2013-04-10 13:34:44

标签: jquery animation

好的,所以我仍然想要了解jQuery。

我几乎得到了它!我需要关闭按钮开始关闭,但因为它在同一个容器中也启动另一个动画。有什么建议吗?

到目前为止,我的代码是jsfiddle链接http://jsfiddle.net/w39Bb/5/

$('.outer-shell').click( function () {
    $(this).animate({
        height: '580px'
    }, 750).addClass('selected');
    $(this).find('.inner-shell').animate({
        height: '550px'
    }, 750);
    $(this).find('.details-click').animate({
        width: "0"
    }, 400).hide(100);
    $(this).find('.image-left-small , .image-right-small').animate({
        opacity: 0
    }).hide(400);
    $(this).find('.image-left-large, .image-right-large').animate({
        opacity: 1
    }).show(0);
    $(this).find('.close').animate({
        opacity: 1
    }, 1000).show();
});

$('h1.close').click(function () {
    $('.outer-shell').animate({
        height: '235px'
    }, 200).removeClass('selected');
    $('.inner-shell').animate({
        height: '229px'
    }, 200);
    $('.details-click').animate({
        width: '299px'
    }, 100).show();
    $('.image-left-small , .image-right-small').animate({
        opacity: 1
    }, 100).show();
    $('.image-left-large, .image-right-large').animate({
        opacity: 0
    }, 400).hide();
});

$('.outer-shell').hover( function () {
  $(this).toggleClass('hover');
});

2 个答案:

答案 0 :(得分:1)

不确定这是否是您要实现的目标但是..添加stopPropagation?

$('h1.close').click(function (e) {
    e.stopPropagation();
    // The rest is the same :)

http://jsfiddle.net/w39Bb/6/

答案 1 :(得分:0)

如果使用$('#div-to-hide').hide()

隐藏另一个不需要的div,它会对你有用吗?