Jquery使用变量设置动画高度?

时间:2013-03-28 04:02:19

标签: jquery html css jquery-animate

这是评论的JSfiddle。我试图使用jquery动画div的高度,这会修改css。但是,由于该项目的动态特性,高度将是未知的,并且可以找到变量。

http://jsfiddle.net/8JwE9/6/

$('span').hide();


  $('.span3').click(function() {


    var pollheight = $(this).find('span').height().toString(); //Trying to increase the DIV += this height (actually trying to toggle it but i'll hit that bridge later.

      //$(this).find('span').append(pollheight);

    $(this).animate({height: '+=80'},1000); //Trying to replace +=80 with a variable

        $(this).find('span').toggle(1000);
    });

1 个答案:

答案 0 :(得分:1)

$(this).animate({height: '+=' + pollHeight},1000);

这应该可以解决问题。