Hey
I’m trying to make a script where I click on an element and then the script would like to do different things…
[CODE]function Obj(id,label){
this.id = id;
this.label = label;
document.write(‘<div id=”‘+this.id+'” value=”‘+this.label+'”></div>’);
[COLOR=”Red”]document.getElementById(this.id).onclick=function(){this.doThis();};[/COLOR]
}
Obj.prototype.doThis = function(){
alert(‘doThis called’);
};
var myObj = new Obj(‘theDiv’,’A button’);
I can see the button in my document but when I tries to click on it, I’m getting an error-message:
[I]“The object doesn’t support the property or the method”
What am I doing wrong?
Thanks for help!