看到我更新到您的代碼.. http://jsfiddle.net/Jaybles/tkVfX/4/
CSS
.mainNav {
float: left;
width: 200px;
height: 100%;
min-width: 150px;
background-color: #e21a22;
}
.active{
font-weight:bold;
}
.mainSide {
font-size: 14px;
list-style: none;
font-family: Helvetica,"Helvetica Neue",Arial,sans-serif;
padding-top: 40px;
width: 143px;
margin-right: auto;
margin-left: auto;
}
.mainSide li a, .mainSide li {
color: #fff;
width: 143px;
display: block;
padding: 2px 0 2px 0;
text-decoration: none;
}
.mainSide ul li a {
width: 125px;
list-style: none;
padding: 6px 0 2px 18px;
}
.mainSide li a:hover {
color: #fdb046;
}
.mainSide li a#active, .mainSide ul li a#active {
color: #fdb046;
background: url("../img/bullet.jpg") right center no-repeat;
}
#subNavSys, #subNavApp, #subNavAcc {
float: left;
width: 200px;
height: 100%;
min-width: 150px;
background-color: #414143;
display:none;
}
#subSideSys, #subSideApp, #subSideAcc {
font-size: 14px;
list-style: none;
font-family: Helvetica,"Helvetica Neue",Arial,sans-serif;
padding-top: 163px;
width: 143px;
margin-right: auto;
margin-left: auto;
}
#subSideSys li a, #subSideSys li, #subSideApp li a, #subSideApp li, #subSideAcc li a, #subSideAcc li {
color: #fff;
width: 143px;
display: block;
padding: 2px 0 2px 0;
text-decoration: none;
}
#subSideSys li a:hover, #subSideApp li a:hover, #subSideAcc li a:hover {
color: #fdb046;
HTML
<div class="mainNav">
<a href="index.php"><img id="top" src="img/metal.jpg" width="143" height="43" alt="Index" /></a>
<ul class="mainSide">
<li><a href="index.php">Home</a></li>
<li><a href="about.php">About us</a></li>
<li>Products
<ul>
<li><a href="#" id="sys">By system</a></li>
<li><a href="#" id="app">By application</a></li>
<li><a href="#" id="acc">Accesories</a></li>
</ul>
</li>
</ul>
</div>
<div id="subNavSys">
<ul id="subSideSys">
<li><a href="#">Sub-menu-1.1</a></li>
<li><a href="#">Sub-menu-1.2</a></li>
<li><a href="#">Sub-menu-1.3</a></li>
</ul>
</div>
<div id="subNavApp">
<ul id="subSideApp">
<li><a href="#">Sub-menu-2.1</a></li>
<li><a href="#">Sub-menu-2.2</a></li>
<li><a href="#">Sub-menu-2.3</a></li>
</ul>
</div>
<div id="subNavAcc">
<ul id="subSideAcc">
<li><a href="#">Sub-menu-3.1</a></li>
<li><a href="#">Sub-menu-3.2</a></li>
<li><a href="#">Sub-menu-3.3</a></li>
</ul>
</div>
JS
$(document).ready(function(){
$("#sys").click(function() {
$("#subNavApp").hide();
$("#subNavAcc").hide();
$("#subNavSys").fadeIn(800);
$('*').removeClass('active');
$(this).addClass('active');
});
$("#app").click(function() {
$("#subNavSys").hide();
$("#subNavAcc").hide();
$("#subNavApp").fadeIn(800);
$('*').removeClass('active');
$(this).addClass('active');
});
$("#acc").click(function() {
$("#subNavSys").hide();
$("#subNavApp").hide();
$("#subNavAcc").fadeIn(800);
$('*').removeClass('active');
$(this).addClass('active');
});
});
後創建的HTML到JS小提琴,而不是PHP版本...... – Neal 2011-05-11 20:05:56
您不能發佈PHP到的jsfiddle。您需要發佈生成的HTML。另外,你對如何使用'id'和'class'有誤解。 'id'用於標識特定項目,而類別定義一組項目,或者爲項目添加其他屬性。 ''應該是''。另一個好處是你可以很容易地將活動類交換到......'$('#app')。removeClass('active'); $('#acc')。addClass('active');' – Dutchie432 2011-05-11 20:12:50
完成,刪除了php部分。這是你的意思嗎? – brunn 2011-05-11 20:14:58