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>

  

上一篇:敏捷遇上UML——软创基地马年大会(深圳站 2014-3-15)


下一篇:DOM-Document对象