jQuery动画效果

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
        div {
            width: 150px;
            height: 300px;
            background-color: pink;
            display: none;
        }
    </style>
    <script src="js/jquery.min.js"></script>
</head>

<body>
    <button>显示</button>
    <button>隐藏</button>
    <button>切换</button>
    <div></div>
    <script>
        $(function() {
            $("button").eq(0).click(function() {
                $("div").slideDown(500);
            })
            $("button").eq(1).click(function() {
                $("div").slideUp(500);
            })
            $("button").eq(2).click(function() {
                    $("div").slideToggle(500);
                })
                // 一般情况下,我们都不加参数直接显示隐藏就可以了
        });
    </script>
</body>

</html>

 

posted @ 2020-08-10 15:45  webpon  阅读(65)  评论(0编辑  收藏  举报