您的位置:首页 > Web前端 > JavaScript

js仿qq分组折叠效果

2016-02-06 00:22 726 查看
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title></title>
<style type="text/css">
ul {
list-style-type: none;
}
.header {
background-color: red;
cursor: pointer;
}
.body {
background-color: greenyellow;
border-style: solid;
border-width: 1px;
}
</style>

<script src="../Scripts/jquery-1.8.2.js"></script>
<script type="text/javascript">
$(function() {
$("#qq li[name=grp]").addClass("header").click(function () {

$(this).nextUntil("li[name=grp]").show("slow");
$(this).siblings("li[name=grp]").nextUntil("li[name=grp]").hide("slow");
});
$("#qq li:not([name=grp])").addClass("body");
$("#qq li:frist").click();
});
</script>
</head>
<body>
<ul id="qq">
<li name="grp">我的好友</li>
<li >张三</li><li>李四</li>

<li name="grp">我的同学</li>
<li>赵三</li><li>同学2</li>

<li name="grp">陌生人</li>
<li>陌生人1</li><li>陌生人2</li><li>陌生人3</li>

</ul>
</body>
</html>


效果图:
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: