Jquery animate height with a variable?

2019-09-18 20:27发布

Here is the commented JSfiddle. I am trying to animate the height of a div using jquery, which modifies the css. However, due to the dynamic nature of this project, the height will be unknown and found with a variable.

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条回答
对你真心纯属浪费
2楼-- · 2019-09-18 20:55
$(this).animate({height: '+=' + pollHeight},1000);

This should do the trick.

查看更多
登录 后发表回答