2013-03-28 73 views
0

這裏是JSfiddle的評論。我正在嘗試使用jquery來動畫div的高度,這會修改css。但是,由於這個項目的動態性,高度將是未知的,並且發現有一個變量。JQuery的動畫高度與變量?

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
$(this).animate({height: '+=' + pollHeight},1000); 

這應該做的伎倆。

+0

這是如此簡單大聲笑。我試着用引號,沒有,大聲笑沒有試圖分開它。 – Ampix0 2013-03-28 04:12:33