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="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>

 

posted on 2017-06-05 14:55  张鑫4477  阅读(305)  评论(0编辑  收藏  举报