我從YouTube教程製作了一個網站。 Here's my test site。如果有幫助,可以使用 here's the tutorial (final step of 3)。尚未使用CSS。加載時爲什麼fadeIn閃爍?
當我點擊菜單中的鏈接。一切都像所想的那樣消失。但在淡出動畫結束時,前一頁閃爍。
Me
我完全不熟悉JavaScript。
的index.php:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>SuperFresh</title>
<link rel="stylesheet" type="text/css" href="css/style.css">
</head>
<body>
<a class="menu_top" href="pages/home.php">Home</a>/
<a class="menu_top" href="pages/portfolio.php">Portfolio</a>/
<a class="menu_top" href="pages/contact.php">Contact</a>/
<div id="content_area"></div>
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script type="text/javascript" src="js/nav.js"></script>
</body>
</html>
nav.js:
$(document).ready(function() {
$('#content_area').load($('.menu_top:first').attr('href'));
});
$('.menu_top').click(function() {
var href=$(this).attr('href');
$('#content_area').hide('slow').load(href).fadeIn('slow');
return false;
});
一個的jsfiddle將有助於 –
你是對的。但我無法讓index.php工作。 = /所以我提交我的測試網站... – naPalmqvist