我正在一個網站上工作,並且正在計劃讓它在某些鏈接上設置值,這將改變頁面加載時顯示的容器。我將如何獲得它,以便鏈接傳遞將用於onload函數的值?傳遞變量在另一個頁面上運行
這裏是我的HTML代碼中的樣機:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Lunch</title>
<link rel="stylesheet" type="text/css" href="style.css">
<script src="http://code.jquery.com/jquery-1.8.3.min.js"></script>
<script src="script.js"></script>
</head>
<body onload="navBar(); dateChange(); tabulate(0);">
<nav>
<ul>
<li><a href="appy.html">Appitizers</a></li>
<li><a href="break.html">Breakfast</a></li>
<li><a href="lunch.html">Lunch</a></li>
<li><a href="dinner.html">Dinner</a></li>
<li><a href="dessert.html">Dessert</a></li>
<li><a href="special.html">Ten-Course Dinner</a></li>
<li><a href="share.html">Send in your Recipes!</a></li>
</ul>
</nav>
<div class="main">
<div class="box">
<ul>
<li><a onclick="tabulate(this.id);" id="1">Chicken Clubhouse Sandwiches</a></li>
<li><a onclick="tabulate(this.id);" id="2">Smokey Tomato Soup</a></li>
</ul>
</div>
<div id="0" class="recipe" style="display: block;">
<div class="tabs">
<a class="tab"> </a>
</div>
<div class="page">
<p>The recipes you'll find here are ones you can use to impress guests at your next get together</p>
</div>
</div> <!--recipe card end-->
<div class="recipe" id="1">
<h1>Chicken Clubhouse Sandwiches</h1>
</div> <!--recipe card end-->
<div class="recipe" id="2">
<h1>Smokey Tomato Soup</h1>
</div> <!--recipe card end-->
</div>
</body>
</html>
,這裏是我的製表功能:
function tabulate(tabNum){
$('.recipe').each(function() {
if(tabNum==this.id){
this.style.display="block";
}
else{
this.style.display="none";
}
});
}
只是一個快速的頭的了:你拼錯了「開胃菜」:) – deckeresq