#2
ID不见了2017-01-26 12:13
|
代码如下:
程序代码:
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8' />
<title>动画</title>
<style>
* {padding:0;margin:0;}
#main {width:100px;height:100px;cursor:pointer;background-color:skyblue;position:relative;}
</style>
<script type='text/javascript' src='./jQuery/jquery-3.1.1.js'></script>
<script>
$(function(){
$('#main').unbind('click').click(function(){
$(this).animate({'left':'800px'},3000); //向右
$('#main').unbind('click').click(function(){
$(this).animate({'top':'500px'},3000); //向下
$('#main').unbind('click').click(function(){
$(this).animate({'left':'0px'},3000); //向左
$('#main').unbind('click').click(function(){
$(this).animate({'top':'0px'},3000); //向上
})
})
})
})
});
</script>
</head>
<body>
<div id='main'></div>
</body>
</html>
<html>
<head>
<meta charset='utf-8' />
<title>动画</title>
<style>
* {padding:0;margin:0;}
#main {width:100px;height:100px;cursor:pointer;background-color:skyblue;position:relative;}
</style>
<script type='text/javascript' src='./jQuery/jquery-3.1.1.js'></script>
<script>
$(function(){
$('#main').unbind('click').click(function(){
$(this).animate({'left':'800px'},3000); //向右
$('#main').unbind('click').click(function(){
$(this).animate({'top':'500px'},3000); //向下
$('#main').unbind('click').click(function(){
$(this).animate({'left':'0px'},3000); //向左
$('#main').unbind('click').click(function(){
$(this).animate({'top':'0px'},3000); //向上
})
})
})
})
});
</script>
</head>
<body>
<div id='main'></div>
</body>
</html>