How can I make a DIV slide in and out?

后端 未结 4 630
陌清茗
陌清茗 2021-01-13 06:49

I am currently learning jQuery. I\'d like to know how to make an image slide in when you click on its edge, then click again and it slides away. Similar to this:

htt

4条回答
  •  粉色の甜心
    2021-01-13 07:26

    In order to use the animate() function add a CSS class to the

    tag that has a height attribute, it can either be in pixels or %, this will be the initial height. After that then you can use the animate().

    $('#mydiv').animate({
        height: 500px
      }, 5000, function() {
        // Animation complete.
      });
    

    This will slide the div to 500px, which will take 5 seconds.

提交回复
热议问题