【发布时间】:2013-06-19 14:08:03
【问题描述】:
该代码非常具有解释性。我在做什么是错的。在A 对象方法中声明的对象的onclick 事件中,如何访问A 对象的a 属性?
function A(){
this.a = 0;
};
A.prototype.myfun= function(){
var b = document.getElementsByClassName("myclassName");
b[0].onclick = function(e){
//How can I get the a property of the A object in here?
this.a = 1;
}
};
我可以以某种方式将其作为这样的参数传递吗?
b[0].onclick = function(e, this){
【问题讨论】:
标签: javascript class object dom-events