手机
当前位置:查字典教程网 >编程开发 >Javascript教程 >jQuery实现动画效果的实例代码
jQuery实现动画效果的实例代码
摘要:复制代码代码如下:table{border:1pxsolid#666;}tabletd{border:1pxsolid#eee;width:...

复制代码 代码如下:

<style type="text/css">

table{border:1px solid #666;}

table td{border:1px solid #eee;width:200px;height:200px;}

img{width:200px;height:200px;border:none;position:relative;}

</style>

<script src="jquery-1.9.1.js" type="text/javascript"></script>

<script type="text/javascript">

$(function () {

// $('img').click(function () {

// $('img').animate({ left: '-=200px' }, 2000).animate({ left: '-=200px' }, 2000)

// .animate({ left: '+=400px', top: '-=200px' }, 1).animate({ left: '-=200px' }, 2000).animate({ left: '-=200px' }, 2000)

// .animate({ left: '+=400px', top: '-=200px' }, 1).animate({ left: '-=200x' }, 2000).animate({ left: '-=200px' }, 2000)

// })

var i = 0; var c = 0;

$('img').click(function () {

if (c < 3) {

if (i == 2 & c == 0) { $('img').animate({ left: '+=400px', top: '-=200px' }, 1); c++ }

else if (i == 2 & c == 1) { $('img').animate({ left: '-=200px' }, 2000); c++ }

else if (i == 2 & c == 2) { $('img').animate({ left: '-=200px' }, 2000); c = 0; i++; }

else if (i == 3 & c == 0) { $('img').animate({ left: '+=400px', top: '-=200px' }, 1); c++ }

else if (i == 3 & c == 1) { $('img').animate({ left: '-=200px' }, 2000); c++ }

else if (i == 3 & c == 2) { $('img').animate({ left: '-=200px' }, 2000); c++; }

else { $('img').animate({ left: '-=200px' }, 2000); i++; }

}

})

})

</script>

</head>

<body>

<table cellpadding="0" cellspacing="0">

<tr>

<td> </td> <td></td> <td></td>

</tr>

<tr>

<td></td> <td></td> <td></td>

</tr>

<tr>

<td></td> <td></td> <td><img src="images/2.gif" alt="奔跑的小人" /></td>

</tr>

</table>

</body>

</html>

【jQuery实现动画效果的实例代码】相关文章:

javasript实现密码的隐藏与显示

jQuery插件实现适用于移动端的地址选择器

jQuery插件制作之全局函数用法实例

jquery简单实现外部链接用新窗口打开的方法

jQuery实现鼠标经过图片变亮其他变暗效果

通过jquery实现页面的动画效果(实例代码)

jquery Ajax 实现加载数据前动画效果的示例代码

jQuery Timelinr实现垂直水平时间轴插件(附源码下载)

javascript实现链接单选效果

Javascript实现飞动广告效果的方法

精品推荐
分类导航