<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>单击时我们改变样式</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
<style type="text/css">
#menu{
width: 300px;
}
//在css中编写#代表id .代表class
.classchild{
background:yellow;
}
hd{
background:gray;
}
div{
padding: 0; margin: 10px 0;
}
div a{
background:green;
}
</style>
<script type="text/javascript" src="jqury/jquery-1.8.2.min.js"></script>
</head>
<body>
<div id="menu">
<span> 第一章 做人的基础</span>
<a>原则</a>
<a>方法</a>
<a>总结</a>
</div>
<div class="classchild">
<span>第二章 做人的准则</span>
<a>原则</a>
<a>方法</a>
<a>总结</a>
</div>
<div class="classchild">
<span>第三章 学会说话</span>
<a>原则</a>
<a>方法</a>
<a>总结</a>
</div>
<script type="text/javascript">
$(".classchild").click(function(){ //获得类名为classchild的元素集 添加单击事件
$("this").addClass("hd") //为当前集中对象添加hd类名
.children("a").show() //把当前对象的的a都显示出来
.end() //重新定位到上次操作的元素
.siblings() //获得兄弟节点
.removeClass("hd") //移除兄弟节点的hd类
.childern("a") //获得兄弟节点的 a元素
.hide(); //隐藏
})
</script>
</body>
</html>
代码未经检测 只提供思想