js callback函数

A callback is a function that is passed as an argument to another function and is executed after its parent function has completed<html><head>

    <title>callback function</title>
    <script language="javascript" type="text/javascript">
        function fParent(callback) {
            alert("This is parent function");
            alert("Now call the callback function");
            callback();
        }

        function fCallback1() {
            alert("This is callback function 1");

        }

        function fCallback2() {
            alert("This is callback function 2");

        }

        function test() {
            fParent(fCallback1);
            fParent(fCallback2);
        }
    </script>
</head>

<body>
    <button onClick=test()>click me</button>
</body>
</html>

  

js callback函数,布布扣,bubuko.com

js callback函数

上一篇:javascript继承之组合继承(三)


下一篇:js 闭包学习笔记