<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>
$(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>
解决方案 »
- jq不能往iframe加东西。。。
- 小div(用来显示重要信息)怎么随着带滚动条的大div滚动而移动(FF)
- <input type='file' />获取值的问题
- 在线跪求!.trigger调用事件返回值是object?怎样才能return false?
- function mm(gg){return document.all ? gg.innerText : gg.textContent}
- [共享]无限级关联下拉菜单[完全js版]
- excel进程怎么老是杀不掉啊??高手进来!!!!!!!
- 滚动条的滚动间距问题
- 这段代码是什么问题呢?
- help!
- HTML如何添加评价JS
- 我该学习什么?谁来告诉我路怎么走下去。。。
<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>