回调函数
来源:互联网 发布:scala 知乎 编辑:程序博客网 时间:2024/06/10 17:48
一段理解回调函数的代码:
<body>
<div id="box">1</div>
<div id="box1">2</div>
<div id="box2">3</div>
<script type="text/javascript">
/*window.onload = function(){
var boxDom = document.getElementById("box");
boxDom.onclick = function(){
this.style.background = "red";
};
}*/
//封装
function clickMe(id,callback){
var boxDom = document.getElementById(id);
boxDom.onclick = function(){
if(callback)callback(this);
};
};
// function callback1(obj){
// obj.style.width = 400 + "px";
// obj.style.background = "red";
// obj.style.height = 250 + "px";
// };
// function callback2(obj){
// window.location.href = "http://www.baidu.com";
// }
clickMe("box",function callback1(obj){
obj.style.width = 400 + "px";
obj.style.background = "red";
obj.style.height = 250 + "px";
});
clickMe("box1",function callback2(obj){
window.location.href = "http://www.baidu.com";
});
clickMe("box2",function callback(obj){
obj.style.width = 40 + "px";
obj.style.background = "green";
obj.style.height = 400 + "px";
});
</script>
</body>
- .NET 回调函数
- 回调函数
- 回调函数
- 回调函数概念
- 回调函数
- 回调函数
- 回调函数
- 回调函数 相关
- delphi 回调函数
- 回调函数
- 回调函数
- 回调函数学习
- 回调函数
- 关于回调函数
- 透析回调函数
- 回调函数
- 什么是回调函数
- 回调函数
- Linux下的Mysql性能测试工具 sysbench
- 代码动态修改shape属性
- 堆和栈的区别
- 生产环境中使用Docker Swarm的一些建议
- 利用windows批处理定期访问数据库远程备份文件【1】
- 回调函数
- 《暗时间》摘要心得2
- cocos2dx3.10 带滚动条的ScrollView和TableView
- 0507学习总结(结构体,共用体,枚举等)
- 【Unity】关于发射子弹、导弹追踪的逻辑(笔记)
- 3.4.1.2_光标的闪烁效果
- java中“53”个关键字(含2个保留字)
- JVM(四) 类的加载
- android闪屏动画