jquery为一个元素设置动画

jquery为一个元素设置动画,jquery,jquery-animate,Jquery,Jquery Animate,我正试图用jQuery创建一个小的动画序列,但无法让它工作 HTML: jQuery: $('.char-lpool .expand').click(function(){ $(this).stop().fadeOut({duration:200}) $(this).parent().stop().animate( {top:"-240"}, {duration:300}, {easing: 'easeOutCubic'}), f

我正试图用jQuery创建一个小的动画序列,但无法让它工作

HTML:

jQuery:

$('.char-lpool .expand').click(function(){
    $(this).stop().fadeOut({duration:200})
    $(this).parent().stop().animate(
        {top:"-240"}, 
        {duration:300},
        {easing: 'easeOutCubic'}), function() {
        $('.char-lpool .talk p.fade').stop().fadeIn({duration:200})
    }
});
通过单击span.expand,我想首先将div.inner向上移动240px,同时淡出span.expand。在这之后,我希望隐藏的p.fade段落淡入

我只能让所有3个动画在同一时间发生,或与上述代码只有前2个动画发生,第三个不工作的所有

我知道这取决于我是如何编写jquery的,但似乎无法让它工作!! 有人能帮忙吗?

您呼叫的位置有点不合适,选项应如下所示:

$('.char-lpool .expand').click(function(){
  $(this).stop().fadeOut({duration:200})
         .parent().stop().animate(
           {top:"-240"}, 
           300,
           'easeOutCubic', 
           function() { $(this).find('p.fade').stop().fadeIn(200); }
         );
});

…或者您可以将最后3个选项作为对象中的单个参数传递,但不能作为单独参数中的不同对象传递。

我在代码中没有看到
class=“talk”
,这是从哪里来的?您使用的是什么版本的jQuery?您指的是HTML中没有的
.char lpool
。是父div吗?抱歉,编辑了html,但没有编辑jquery类名——更不用说Nicks在下面找到了答案并解决了问题。谢谢。谢谢尼克——你似乎回答了我的几个问题!
$('.char-lpool .expand').click(function(){
    $(this).stop().fadeOut({duration:200})
    $(this).parent().stop().animate(
        {top:"-240"}, 
        {duration:300},
        {easing: 'easeOutCubic'}), function() {
        $('.char-lpool .talk p.fade').stop().fadeIn({duration:200})
    }
});
$('.char-lpool .expand').click(function(){
  $(this).stop().fadeOut({duration:200})
         .parent().stop().animate(
           {top:"-240"}, 
           300,
           'easeOutCubic', 
           function() { $(this).find('p.fade').stop().fadeIn(200); }
         );
});