jquery实现animate的使用

本文介绍了一种使用jQuery实现的图片点击动画效果,并展示了一个简单的表格布局示例。通过CSS样式设置,定义了图片的初始位置及外观,利用jQuery动画方法使图片在被点击时移动并最终隐藏。

 

 

 <title></title>
    <script src="jquery-1.9.1.js" type="text/javascript"></script>
    <style type="text/css">
        .imgclass
        {
            width: 100px;
            height: 100px;
            border: solid 1px red;
            position: absolute;
            left: 20px;
            top: 20px;
        }
    </style>
    <script type="text/javascript">
        $(function () {
            $('img').click(function () {
                $(this).animate({ left: '+=130px' }, 2000).animate({ left: '+=130px' }, 2000).animate({ top: '+=130px' }, 2000).animate({ left: '-=130px' }, 2000).animate({ left: '-=130px' }, 2000).animate({ top: '+=130px' }, 2000).animate({ left: '+=130px' }, 2000).animate({ left: '+=130px' }, 2000, function () {
                    $('img').hide(5000);
                })
            })
        });
    </script>
</head>
<body>
    <div>
        <img alt="" src="images/1.jpg" class="imgclass" />
        <table border="1" width="400px" height="400px;">
            <tr id="table1">
                <td align="center">
                    1
                </td>
                <td align="center">
                    2
                </td>
                <td align="center">
                    3
                </td>
            </tr>
            <tr id="table2">
                <td align="center">
                    6
                </td>
                <td align="center">
                    5
                </td>
                <td align="center">
                    4
                </td>
            </tr>
            <tr id="table3">
                <td align="center">
                    7
                </td>
                <td align="center">
                    8
                </td>
                <td align="center">
                    9
                </td>
            </tr>
        </table>
    </div>
</body>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值