gpt4 book ai didi

带有变量的 Jquery 动画高度?

转载 作者:太空宇宙 更新时间:2023-11-04 15:07:59 25 4
gpt4 key购买 nike

这是注释的 JSfiddle。我正在尝试使用修改 css 的 jquery 为 div 的高度设置动画。但是,由于该元素的动态特性,高度将是未知的,并通过变量找到。

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);
});

最佳答案

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

这应该可以解决问题。

关于带有变量的 Jquery 动画高度?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15674068/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com