<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>1-5-1</title>
<style type="text/css">
#menu {
width:300px;
}
.has_children{
background : #555;
color :#fff;
cursor:pointer;
}
.highlight{
color : #fff;
background : green;
}
div{
padding:0;
}
div a{
background : #888;
display : none;
float:left;
width:300px;
}
</style>
<!-- 引入 jQuery -->
<script src="../../scripts/jquery-1.3.1.js" type="text/javascript"></script>
<script type="text/javascript">
//等待dom元素加載完畢.
$(document).ready(function(){
$(".has_children").click(function(){
$(this).addClass("highlight") //為當前元素增加highlight類
.children("a").show().end() //將子節點的a元素顯示出來并重新定位到上次操作的元素
.siblings().removeClass("highlight") //獲取元素的兄弟元素,并去掉他們的highlight類
.children("a").hide(); //將兄弟元素下的a元素隱藏
});
});
</script>
</head>
<body>
<div id="menu">
<div class="has_children">
<span>第1章-認識jQuery</span>
<a>1.1-JavaScript和JavaScript庫</a>
<a>1.2-加入jQuery</a>
<a>1.3-編寫簡單jQuery代碼</a>
<a>1.4-jQuery對象和DOM對象</a>
<a>1.5-解決jQuery和其它庫的沖突</a>
<a>1.6-jQuery開發工具和插件</a>
<a>1.7-小結</a>
</div>
<div class="has_children">
<span>第2章-jQuery選擇器</span>
<a>2.1-jQuery選擇器是什么</a>
<a>2.2-jQuery選擇器的優勢</a>
<a>2.3-jQuery選擇器</a>
<a>2.4-應用jQuery改寫示例</a>
<a>2.5-選擇器中的一些注意事項</a>
<a>2.6-案例研究——類似淘寶網品牌列表的效果</a>
<a>2.7-還有其它選擇器么?</a>
<a>2.8-小結</a>
</div>
<div class="has_children">
<span>第3章-jQuery中的DOM操作</span>
<a>3.1-DOM操作的分類</a>
<a>3.2-jQuery中的DOM操作</a>
<a>3.3-案例研究——某網站超鏈接和圖片提示效果</a>
<a>3.4-小結</a>
</div>
</div>
</body>
</html>