其他分享
首页 > 其他分享> > JQuery动画

JQuery动画

作者:互联网

JQuery高级

<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>Insert title here</title>
    <script type="text/javascript" src="/js/jquery-3.6.0.min.js"></script>

    <script>
        //按钮隐藏div
        function hideFn() {
           /*$("#showDiv").hide("slow","swing",function () {
                alert("隐藏了");
            });*/

            // $("#showDiv").hide(5000, "swing");

            // $("#showDiv").slideUp("slow");

            $("#showDiv").fadeOut("slow");
        }
        //按钮显示div
        function showFn() {
            /*$("#showDiv").show("slow","swing",function () {
                alert("显示了");
            });*/

            // $("#showDiv").show(5000, "linear");

            // $("#showDiv").slideDown("slow");

            $("#showDiv").fadeIn("slow");
        }
        //切换div显示和隐藏
        function toggleFn() {
            // $("#showDiv").toggle("slow","swing",function () {
            //     alert("切换了");
            // });

            // $("#showDiv").slideToggle("slow");

            $("#showDiv").fadeToggle("slow");
        }
    </script>
</head>
<body>
<input type="button" value="点击按钮隐藏div" onclick="hideFn()">
<input type="button" value="点击按钮显示div" onclick="showFn()">
<input type="button" value="点击按钮切换div显示和隐藏" onclick="toggleFn()">

<div id="showDiv" style="width:300px;height:300px;background:pink">
    div显示和隐藏
</div>
</body>
</html>

标签:JQuery,动画,slow,function,easing,showDiv,speed,fn
来源: https://www.cnblogs.com/ailhy/p/16607204.html