首页 > 代码库 > jquery下拉菜单[复合事件hover制作]

jquery下拉菜单[复合事件hover制作]

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <script src=http://www.mamicode.com/"js/jquery-1.7.2.min.js"></script>
    <title></title>
    <style type="text/css">
        .div1 {
            position: relative;
            width: 100px;
            height: 50px;
            background-color: red;
            float: left;
            margin-left: 20px;
        }

        .div2 {
            position: absolute;
            width: 100%;
            height: 0px;
            top: 50px;
            background-color: green;
        }
    </style>
</head>
<body>
    <div class="div1">
        <div class="div2"></div>
    </div>

    <div class="div1">
        <div class="div2"></div>
    </div>

    <div class="div1">
        <div class="div2"></div>
    </div>

    <div class="div1">
        <div class="div2"></div>
    </div>

    <div class="div1">
        <div class="div2"></div>
    </div>
</body>
</html>
<script type="text/javascript">
    $(".div1").hover(
        function () {
            var aaa = $(this).children(".div2:eq(0)");
            aaa.stop().animate({ height: "300px" }, 500)
        },
        function () {
            var aaa = $(this).children(".div2:eq(0)");
            aaa.stop().animate({ height: "0px" }, 500)
        }
        );
</script>

 

jquery下拉菜单[复合事件hover制作]