首页 > 代码库 > jQuery示例

jQuery示例

1.菜单栏示例

技术分享
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        #menu{
            border: 1px solid red;
            width: 200px;
            height: 600px;
        }
        .menu1{
            background-color: #4876FF;
            height: 40px;

        }
        .one{
            padding-left: 50px;
        }
        .one1{
            padding-left: 50px;
        }
        .hide{
            display: none;
        }
        .content span{
            display: block;
            padding-left: 100px;
        }


        .see{
            display: none;
        }
    </style>
</head>
<body>

<div id="menu">
    <div>
        <div class="menu1">菜单1</div>
        <div class="content see">
            <span>1</span>
            <span>2</span>
            <span>3</span>
            <span>4</span>
        </div>
    </div>
        <div>
        <div class="menu1">菜单2</div>
        <div class="content see">
            <span>1</span>
            <span>2</span>
            <span>3</span>
            <span>4</span>
        </div>
    </div>
        <div>
        <div class="menu1">菜单3</div>
        <div class="content see">
            <span>1</span>
            <span>2</span>
            <span>3</span>
            <span>4</span>
        </div>
    </div>


</div>

<script src="high/jquery-1.12.4%20(1).js"></script>
<script>
    $(".menu1").click(function () {
        $(this).next().removeClass("see");
        $(this).parent().siblings().find(".content").addClass("see")
    })
</script>
</body>
</html>
View Code

 

jQuery示例