V
vunet
How can I initialize a function within the object on click of this
objects link element appended to body? Simply, see onclick which DOES
initialize my doSomething function but does NOT see myArray:
fucntion Test(){
this.myArray = new Array();
this.doSomething = function(){
this.myArray.push("blah")
}
var aLink = document.createElement("a")
aLink.innerHTML = "Do something";
aLink.onclick = this.doSomething;
document.body.appendChuild(aLink);
}
new Test();
Error: myArray has no properties
objects link element appended to body? Simply, see onclick which DOES
initialize my doSomething function but does NOT see myArray:
fucntion Test(){
this.myArray = new Array();
this.doSomething = function(){
this.myArray.push("blah")
}
var aLink = document.createElement("a")
aLink.innerHTML = "Do something";
aLink.onclick = this.doSomething;
document.body.appendChuild(aLink);
}
new Test();
Error: myArray has no properties