Js 自定义回调函数

转自:https://www.cnblogs.com/laj12347/p/4184433.html
<!doctype html>
<html lang="es">
<head>
    <meta charset="UTF-8">
    <title>HTML5</title>
    <link rel="stylesheet" href="#" /><!-- css样式  -->
    <script src="http://libs.baidu.com/jquery/1.10.2/jquery.min.js"></script>
</head>
<script type="text/javascript">
$(document).ready(function(){
    /**
     * 回调函数测试方法
     
     * @param callback
     *            被回调的方法
     */ 
    function testCallback(callback) { 
        alert('come in!'); 
        callback(); 
    
      
    /**
     * 开始测试方法
     */ 
    testCallback(function(){ 
        alert('a');
        $("#div1").fadeIn();
        $("#div2").fadeIn("slow");
        $("#div3").fadeIn(3000);
    });  
});  
</script>
<body>
    <div class="test"></div>
    <div id="div1" style="width:80px;height:80px;display:none;background-color:red;"></div><br>
    <div id="div2" style="width:80px;height:80px;display:none;background-color:green;"></div><br>
    <div id="div3" style="width:80px;height:80px;display:none;background-color:blue;"></div>
</body>
</html>
点赞

发表回复

电子邮件地址不会被公开。必填项已用 * 标注