【问题标题】:Jquery animate height with a variable?Jquery用变量动画高度?
【发布时间】:2013-03-18 10:22:35
【问题描述】:

这里是注释的 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);
    });

【问题讨论】:

    标签: jquery html css jquery-animate


    【解决方案1】:
    $(this).animate({height: '+=' + pollHeight},1000);
    

    这应该可以解决问题。

    【讨论】:

    • 这太简单了,哈哈。我尝试使用引号,没有,大声笑没有尝试将它分开。
    猜你喜欢
    • 2015-02-27
    • 2013-06-06
    • 2011-06-03
    • 1970-01-01
    • 1970-01-01
    • 2016-08-25
    • 2012-03-01
    • 2012-04-20
    • 2011-06-25
    相关资源
    最近更新 更多