zoukankan      html  css  js  c++  java
  • jQuery实现折叠下拉效果

    <!DOCTYPE html>
    <html lang="en">
    <head>
    <meta charset="UTF-8">
    <title>折叠下拉效果</title>
    <style>
    *{
    margin: 0;
    padding: 0;
    }
    .main{
    500px;
    margin: 0 auto;
    border: 1px solid #ccc;
    padding: 8px;
    }
    h3{
    font-size: 16px;
    font-weight: normal;
    height: 30px;
    line-height: 1.5;
    background-color: #F6F6F6;
    border: 1px solid #c5c5c5;
    padding: 2px;
    margin-top: -1px;
    }
    h3 i{
    display: inline-block;
    12px;
    height: 20px;
    vertical-align: -28%;
    background: url(./images/bg.png) no-repeat;
    background-position: 0 0;
    }
    .on{
    background-position: -32px 0;
    }
    .main div{
    border: 1px solid #c5c5c5;
    margin-top: -1px;
    height: 100px;
    display: none;
    padding: 2px;
    }
    .main div:nth-child(2){
    display: block;
    }
    .active{
    background: #007FFF;
    color: #fff;
    }
    </style>
    </head>
    <body>
    <div class="main">
    <h3 class="active"><i class="on"></i>标题1</h3>
    <div>段落1段落1段落1段落1段落1段落1段落1段落1段落1段落1段落1段落1段落1段落1</div>
    <h3><i></i>标题2</h3>
    <div>段落2段落2段落2段落2段落2段落2段落2段落2段落2段落2段落2段落2段落2段落2</div>
    <h3><i></i>标题3</h3>
    <div>段落3段落3段落3段落3段落3段落3段落3段落3段落3段落3段落3段落3段落3段落3</div>
    <h3><i></i>标题4</h3>
    <div>段落4段落4段落4段落4段落4段落4段落4段落4段落4段落4段落4段落4段落4段落4</div>
    </div>

    <script src="http://cdn.bootcss.com/jquery/1.11.1/jquery.min.js"></script>
    <script>
    $(function(){
    $("h3").click(function(){
    var status=$(this).next("div").css("display");
    console.log($(this).css("display"));
    if (status=="none") {
    $(this).addClass("active").next("div").slideDown().siblings('div').slideUp();
    $(this).siblings('h3').removeClass('active').find("i").removeClass('on');
    $(this).find('i').addClass('on');
    }

    })
    })
    </script>
    </body>
    </html>

  • 相关阅读:
    关于系统中账号注册登录的一些想法
    关于Data URLs svg图片显示出错和浏览器URL hash #
    我的Spring Boot学习记录(一):自动配置的大致调用过程
    Java工具类——通过配置XML验证Map
    关于HTTPS的简要内容
    Effective Java目录
    Java 初始化a=2 打印a+++a++为5
    Spring SpringMVC MyBatis配置笔记
    Debian8 部署 laravel 5.3 (php7.0 + nginx)
    Intellij idea配置springMvc4.2.6
  • 原文地址:https://www.cnblogs.com/chabai/p/5895231.html
Copyright © 2011-2022 走看看