How to fade in a div on page load?

后端 未结 3 1706
被撕碎了的回忆
被撕碎了的回忆 2021-02-08 07:44

I\'m using jQuery. I need a div to fade in when the page loads.

How can I achieve this?

3条回答
  •  无人及你
    2021-02-08 08:14

    It cannot be simpler:

    $(function(){  // $(document).ready shorthand
      $('#monster').fadeIn('slow');
    });
    

    If your div is not initially hidden, you could hide it before the animation:

     $('#monster').hide().fadeIn('slow');
    

    The speed parameter can be 'slow', 'normal', 'fast' or the number of milliseconds to run the animation.

提交回复
热议问题