手机
当前位置:查字典教程网 >编程开发 >Javascript教程 >animate动画示例(泪奔的小孩)及stop和delay的使用
animate动画示例(泪奔的小孩)及stop和delay的使用
摘要:复制代码代码如下:img{width:150px;height:200px;position:relative;}td{width:150p...

复制代码 代码如下:

<head>

<title></title>

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

<style type="text/css">

img

{

width:150px;

height:200px;

position:relative;

}

td{width:150px;height:200px;}

table{border:solid 1px black;}

</style>

<script type="text/javascript">

$(function () {

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

$(this).animate({ left: '+=150px' }, 2000).animate({ left: '+=150px' }, 2000).animate({ top: '+=200px' }, 2000).animate({ left: '-=150px' }, 2000).animate({ left: '-=150px' }, 2000).animate({ top: '+=200px' }, 2000).animate({ left: '+=150px' }, 2000).animate({ left: '+=150px' }, 2000);

})

//停止动画,当一个元素有一个动画队列时,停止的是当前动画,紧接着执行下一个动画

$('#btnStop').click(function () {

$('img').stop();

})

$('#btnYanChi').click(function () {

$('img').delay(2000).hide(2000);

})

})

</script>

</head>

<body>

<table>

<tr>

<td>

<img src="images/泪奔1.gif" />

</td>

<td>

</td>

<td>

</td>

</tr>

<tr>

<td>

</td>

<td>

</td>

<td>

</td>

</tr>

<tr>

<td>

</td>

<td>

</td>

<td>

</td>

</tr>

</table>

<input id="btnStop" type="button" value="stop" />

<input id="btnYanChi" type="button" value="延迟执行" />

</body>

【animate动画示例(泪奔的小孩)及stop和delay的使用】相关文章:

JavaScript中fixed()方法的使用简介

JavaScript中的toLocaleLowerCase()方法使用详解

简介JavaScript中的getUTCFullYear()方法的使用

JavaScript的while循环的使用

简述JavaScript中正则表达式的使用方法

简介JavaScript中的setTime()方法的使用

JavaScript中的blink()方法的使用

JavaScript中的replace()方法使用详解

JavaScript实现简单的数字倒计时

JavaScript正则表达式中的global属性的使用

精品推荐
分类导航