开发者

How can i animate a div class using auto instead of a fixed number?

for the life of me I cannot figure this out, I am trying to animate a div to its natural height, however jquery only lets me drop in values. I would like this to auto size depending on the amount of content...the line in the code I am having trouble with is:

$elem.addClass('current').animate({height: '100'},300);

I would like 100 to be auto. PLEASE HELP!

Here is the code:

            $list.find('.st_arrow_down').live('click',function(){
                var $this = $(this);
                hideThumbs();
                $this.addClass('st_arrow_up').removeClass('st_arrow_down');
                var $elem = $this.closest('li');
                var $plus = $this.closest('li').height();
                $elem.addClass('current').animate({height: '100'},300);
                var $thumbs_wrapper = $this.parent().next();
                $thumbs_wrapper.show(200);
            });
            $list.find('.st_arrow_up').live('click',function(){
                var $this = $(this);
                $this.addClass('st_arrow_down').removeClass('st_arrow_up');
                hideThumbs();
      开发者_Go百科      });


You mean computed height?

$elem.addClass('current').animate({height: $elem.height()},300);

This won’t work if you have a fixed height set for $elem using CSS.


The only possibility I see is to clone the node (remove the fixed height), place it somewhere offscreen, and measure it.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜