标签:btn argument and turn context his return on() apply
var handler={
message:"Event handled.",
handlerFun:function(){
alert(this.message)
}
};
//document.getElementById(‘btnTest‘).onclick=handler.handlerFun;
/* document.getElementById(‘btnTest‘).onclick=function(){
handler.handlerFun();
} */
function bind(fn,context){
return function(){
return fn.apply(context,arguments);
};
}
document.getElementById(‘btnTest‘).onclick=bind(handler.handlerFun,handler);
标签:btn argument and turn context his return on() apply
原文地址:http://www.cnblogs.com/jayruan/p/6815587.html