jQuery animate height

前端 未结 3 1674
刺人心
刺人心 2020-12-01 14:13

I have a button and a div with inside some text:

Click me

Lot of text here....

3条回答
  •  無奈伤痛
    2020-12-01 15:12

    This thread is not the newest, but here's another approach.

    I have been dealing with the very same issue today and could not get it to work properly. Even with the correct height calculated with height: auto applied, the animation would not give me the correct results. I tried putting it in $(window).load instead of $(document).ready, which helped a little, but still cut off my last line of text.

    Instead of animating the height itself, I was able to resolve the issue by adding and removing a hidden class to my div dynamically. If you use jQuery-UI, you can apply a duration to these effects. This seems to work in all browsers, too.

    Here's a working exampe.

提交回复
热议问题