您的位置:首页 > 其它

回调函数

2015-07-05 09:06 281 查看
首先有一个函数执行,在传出指定个数参数的参数之后,再传入一个函数,就会实现在之前那个函数执行完之后,在执行这个函数,这个函数为回调函数

<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>回调函数</title>
<script type="text/javascript" src="../js/jquery-1.7.1.min.js"></script>
<script type="text/javascript">
$(function(){
$('#box').mouseover(function(){
$(this).animate({'width':'300px'},500,function(){//当执行完前面的函数(宽度变为300),在执行这个匿名函数
$(this).animate({'height':'300px'},500)//高度变为300
})
})
})

</script>
<style type="text/css">
#box{
width:100px;
height:100px;
background: red;
}
</style>
</head>
<body>
<div id="box"></div>

</body>
</html>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: