JavaScript 事件绑定函数
function panTest(m_onClickFun) { var This = this; This.onClickFun = m_onClickFun; /* This.onClickFun = function () { $('#console').append("click\n\r"); } */ function AddEvent(element,e,fn) { if(element.addEventListener){ element.addEventListener(e,fn,false); } else { element.attachEvent('on'+e,fn); } } This.listen = document.getElementById('listen'); AddEvent(This.listen,'click',This.onClickFun); } function myClick(){ $('#console').append("panshangqi\n\r"); } var pan = new panTest(myClick);