I'm having a hard time by trying and decipher this one. I tried googling around but couldn't come up with an answer (may be I just don't know the proper search terms)
I wrote a custom object, and inside this object I set an onfocus event for a newly created input box (I changed it for an onclick for test purposes), the function inside this event needs to use one of the properties of the object, but it just can't. It keeps getting "undefined" value.
Here's a part of the code:
Expand|Select|Wrap|Line Numbers
- function customObject() {
- this.myProperty = "testProperty";
- var t = document.createElement("INPUT");
- t.setAttribute("type", "text");
- document.body.appendChild(t);
- t.onclick =
- function() {
- alert(this.myProperty);
- };
- }
Do you have any ideea how this can be done?
Thanks