我真的很难理解这个概念,我想如果我在自己的代码上看到它可能会点击它。我真的很想利用回调函数,同时仍然保持面向对象的方法。感谢您提供的任何帮助!
//adds functionality to buttons
addClickEvent(newDataCollect,function() {addClickEvent(dataSubmitBtn, function(){testAjax(dataForm.elements);});
function addClickEvent(elem,click,addtl) {
var nwClickEvent = new elemEvents(elem,click,addtl);
nwClickEvent.onClick();
}
//add click event object & properties
function elemEvents(elem,click,addtl) {
this.elem = elem;
this.click = click;
this.addtl = addtl;
}
//add click event object method
elemEvents.prototype = {
onClick: function() {this.elem.onclick = this.click;}
}