Jquery animate height with a variable? [英] Jquery animate height with a variable?
本文介绍了Jquery animate height with a variable?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这里是评论的JSfiddle。我试图动画的div的高度使用jquery,修改css。然而,由于这个项目的动态性质,高度将是未知的,并且存在一个变量。
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.
$('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);
});
推荐答案
$(this).animate({height: '+=' + pollHeight},1000);
这应该可以做。
这篇关于Jquery animate height with a variable?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文