function panTest(m_onClickFun) { var This = this; This.onClickFun = m_onClickFun; /* This.onClickFun = function () { $('#console').append("click "); } */ 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 "); } var pan = new panTest(myClick);