jquery折叠卡片

本文介绍了如何利用jQuery库创建折叠卡片功能。教程中提到,关键在于正确引入jQuery包,并结合适当的JavaScript代码来实现卡片的展开和收起效果。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

jquery折叠卡片

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title></title>
    <style type="text/css">
        *{
            margin: 0px;
            padding: 0px;
        }
        .box{
            width: 400px;
            height: 260px;
            border: 1px solid black;
            margin: 100px auto;
        }
        .box ul{
            list-style: none;
        }
        .box ul li h3{
            width: 400px;
            height: 40px;
            background-color: orange;
        }
        .box ul li h3.cur{
            background-color: red;
        }
        .box ul li .info{
            width: 400px;
            height: 100px;
            background-color: #ccc;
            display: none;
        }
        .box ul li.first .info{
            display: block;
        }
    </style>
   <script type="text/javascript" src="jquery-3.1.1.min.js"></script>
    <script type="text/javascript">
        $(document).ready(function(){
            $("h3").click(function(){
                $("h3").removeClass('cur')
                $(this).addClass('cur')
                $(".info").slideUp();      
                $(this).siblings().slideDown();
            })
        })
    </script>
</head>
<body>
    <div class="box">
        <ul>
            <li class="first">
                <h3>标题1</h3>
                <div class="info"></div>
            </li>
            <li>
                <h3>标题2</h3>
                <div class="info"></div>
            </li>
            <li>
                <h3>标题3</h3>
                <div class="info"></div>
            </li>
            <li>
                <h3>标题4</h3>
                <div class="info"></div>
            </li>
        </ul>
    </div>
</body>
</html>

注意:要引进jquery的包,版本不一定是3.1.1版本;可以是其他版本

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值