[php学习十七]JQuery练习2-动画

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>JQuery效果练习</title>
    <script src="jquery-3.1.0.min.js"></script>
    <script>
        $(document).ready(function () {
            $("p").css({"margin-bottom":"0px"});
            $("#btn1").click(function () {
                $("#divHide").toggle(1000,function () {
                    alert($(this).is(":hidden") == true ?"被隐藏了哦~!":"显示出来啦~!");
                });
            });
            $("#btn2").click(function () {
                $("#divFade").fadeToggle(1000,function () {
                    alert($(this).is(":hidden") == true ?"被隐藏了哦~!":"显示出来啦~!");
                });
            });
            $("#btn3").click(function () {
                $("#divslide").slideToggle(1000,function () {
                    alert($(this).is(":hidden") == true ?"被隐藏了哦~!":"显示出来啦~!");
                });
            });
            $("#btn4").click(function () {
                /*这个链式编程真是爽翻了~*/
                $("#divanimate").css({position:"absolute"})
                        .animate({left: '300px'},1000)
                        .animate({height: '200px'}, 1000)
                        .animate({width: '200px'}, 1000)
                        .animate({fontSize:'40px'},1000)
                        .animate({fontSize:'15px'},1000)
                        .animate({width: '100px'}, 1000)
                        .animate({height: '100px'}, 1000)
                        .animate({left: '10px'},1000,function () {
                            $(this).css({position:'static'});
                        });
            });

        });
    </script>
</head>
<body>
<div style="clear: both">
    <p><small>显示隐藏、淡出淡入、滑上滑下练习</small></p>
    <div id="divHide" style="float: left; width: 100px; height: 100px; background-color: blue"></div>
    <div id="divFade" style="float: left; width: 100px; height: 100px; background-color: rebeccapurple"></div>
    <div id="divslide" style="float: left; width: 100px; height: 100px; background-color: red"></div>
</div>
<div style="clear: both">
    <button id="btn1"  style=" left: 0; font-size: 15px">显示隐藏</button>
    <button id="btn2"  style=" left: 0; font-size: 15px">淡出淡入</button>
    <button id="btn3"  style=" left: 0; font-size: 15px">滑上滑下</button>
</div>
<div style="clear: both">
    <p><small>动画练习</small></p>
    <!--默认情况下,所有 HTML 元素都有一个静态位置,且无法移动。如需对位置进行操作,要记得首先把元素的 CSS position 属性设置为 relative、fixed 或 absolute!-->
    <div id="divanimate"  style="float: left; width: 100px; height: 100px; background-color: darkolivegreen; ">Hello World</div>
</div>
<div style="clear: both">
    <button id="btn4" style="font-size: 15px">动画展示</button>
</div>
</body>
</html>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值