在js高級程序設計書上,控制臺上出現(xiàn)Uncaught ReferenceError: bind is

科技 未結(jié) 2 1908
歐美范兒容嬤嬤
歐美范兒容嬤嬤 2022-06-26 11:04

var EventUtil = { addHandler:function(element,type,handler){ if(element.addEventListener){ element.addEventListener(type,handler,false); }else if(element.attachEvent){ element.attachEvent("on"+type,handler); }else{ element["on"+type] = handler; } }, removeHandler:function(element,type,handler){ if(element.removeEventListener){ element.removeEventListener(type,handler,false); }else if(element.detachEvent){ element.detachEvent("on"+type,handler); }else{ element["on"+type] = null; } } }; var handler={ message:"Event handled", handleClick:function(event){ alert(this.message); } }; var btn=document.getElementById("btn"); EventUtil.affffdHandler(btn,"click",bind(handler.handleClick,handler));

2條回答
提交回復