jQuery, hide a div without disturbing the rest of the page

前端 未结 6 496
难免孤独
难免孤独 2020-12-17 21:37

Consider the page as below (pseudocode)

&l
6条回答
  •  轮回少年
    2020-12-17 22:06

    .fadeOut() finishes with a display: none;, if you don't want to do that, use .fadeTo() instead (which won't set display at the end), like this:

    $("header").delay(5000).fadeTo(2000, 0);
    

    (note this uses the built-in .delay() function)

    You can try out a full demo here, with the hover functionality fading and not causing movement as well, like this:

    $("header").hover(function() { 
      $(this).fadeTo(600, 1); 
    }, function() { 
      $(this).fadeTo(600, 0); 
    });
    

提交回复
热议问题