回调函数

首先有一个函数执行,在传出指定个数参数的参数之后,再传入一个函数,就会实现在之前那个函数执行完之后,在执行这个函数,这个函数为回调函数

<!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>

 

posted @ 2015-07-05 09:06  飘逸110  阅读(173)  评论(0编辑  收藏  举报