jQuery How do you get an image to fade in on load?

前端 未结 13 1615
情话喂你
情话喂你 2020-11-29 04:21

All I want to do is fade my logo in on the page loading. I am new today to jQuery and I can\'t managed to fadeIn on load please help. Sorry if this question has already been

13条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-11-29 04:30

    The key is to use $(window).load(function(){} so we know the image is loaded. Hide the image via the css function then fade it in using fadeIn:

    $(function() {
    
      $(window).load(function(){
        $('#logo').css({visibility: 'visible', opacity: 0}).fadeIn(1000);
      });
    
    });
    

    Idea from: http://www.getpeel.com/

提交回复
热议问题