function a(callback) {
callback();
}
function b(){
alert("我是回调函数b");
}
a(b);上面是一个简单的回调函数的示例,我可以理解。下面的代码中,将ligthOn,lightOff都称为回调函数,我一下想不通,请解释一下。<html><head><title>使用JavaScript指定事件响应函数</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>
1 回答

慕的地6264312
TA贡献1817条经验 获得超6个赞
添加回答
举报
0/150
提交
取消