js仿qq分组折叠效果

<!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>

效果图:

转载于:https://www.cnblogs.com/zhaojiedi1992/p/zhaojiedi_js_001.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值