function a(callback) {
callback();
}
function b(){
alert("我是回調(diào)函數(shù)b");
}
a(b);上面是一個簡單的回調(diào)函數(shù)的示例,我可以理解。下面的代碼中,將ligthOn,lightOff都稱為回調(diào)函數(shù),我一下想不通,請解釋一下。<html><head><title>使用JavaScript指定事件響應(yīng)函數(shù)</title><meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript">function lightOn(){ document.images[0].src = "eg_bulbon.gif";
}function lightOff(){ document.images[0].src = "eg_bulboff.gif";
}window.onload = function(){ document.images[0].onmouseover = lightOn; document.images[0].onmouseout = lightOff;
}</script></head><body><img src="eg_bulboff.gif" /></body></html>
這個回調(diào)函數(shù)如何理解?
富國滬深
2018-09-05 09:29:47