2013-03-22 82 views
0

當在我的網站上加載新頁面時,我希望舊頁面的主內容(位於正文內的div內,以排除頁腳和頁眉)淡出,並通過使用jQuery來淡入新頁面的主要內容。我的代碼基本上是:淡入淡出/在頁面加載部分

<html> 

<head> -random header info- (also where I figured the jQuery would go?) 
</head> 

    <body> 

    <div id="header"> 
    </div> 

    <div id="main"> - main content of site - 
    </div> 

    <div id="footer"> 
    </div> 

    </body> 

</html> 

我只是想淡出和影響:<div id="main">我該怎麼辦呢?

+0

你預計新的內容從何而來? – dbarnes 2013-03-22 02:15:21

回答

1

試試這個,一定要包括jquery庫。

$(document).ready(function(){ 
    $("div#main").fadeOut(); 
}); 

淡入,添加style="display:none"到您的DIV,並改變​​到fadeIn()

1

在你的document.ready: - 淡出: -

$('#main').fadeOut('slow'); 

淡入: -

$('#newcontent').fadeIn('slow');