<script type="text/javascript">
$(document).click(function(){
$("has_children").addClass("highlight").children("a").show().end().siblings().removeClass("highligt").children("a").hide();
});
</script>
<style type="text/css">
#menu{width:300px;}
.has_children{background:#555;color:#FFF; cursor:pointer;}
.highlight{color:#fff; background:green;}
div{padding:0;margin:10px 0;}
div a{background:#888;display:none;float:left;width:300px;}
</style><title>无标题文档</title>
</head><body>
<div id="menu">
<div class="has_children">
<span>第一章</span>
<a>1.1asf</a>
<a>1.2asfasf</a>
<a>1.3asf</a>
</div>
<div class="has_children">
<span>第二章</span>
<a>2.1asf</a>
<a>2.2asfasf</a>
<a>2.3asf</a>
</div>
<div class="has_children">
<span>第三章</span>
<a>3.1asf</a>
<a>3.2asfasf</a>
<a>3.3asf</a>
</div>
</div>
</body>
</html>

解决方案 »

  1.   

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <script  src="jquery-1.4.3.js" type="text/javascript" ></script><script type="text/javascript">
    $(document).click(function(){
    $("has_children").addClass("highlight").children("a").show().end().siblings().removeClass("highligt").children("a").hide();
    });
    </script>
    <style type="text/css">
    #menu{width:300px;}
    .has_children{background:#555;color:#FFF; cursor:pointer;}
    .highlight{color:#fff; background:green;}
    div{padding:0;margin:10px 0;}
    div a{background:#888;display:none;float:left;width:300px;}
    </style><title>无标题文档</title>
    </head><body>
    <div id="menu">
    <div class="has_children">
    <span>第一章</span>
    <a>1.1asf</a>
    <a>1.2asfasf</a>
    <a>1.3asf</a>
    </div>
    <div class="has_children">
    <span>第二章</span>
    <a>2.1asf</a>
    <a>2.2asfasf</a>
    <a>2.3asf</a>
    </div>
    <div class="has_children">
    <span>第三章</span>
    <a>3.1asf</a>
    <a>3.2asfasf</a>
    <a>3.3asf</a>
    </div>
    </div>
    </body>
    </html>
      

  2.   

    (".has_children")