JavaScript prototype 'das' Problem

Dies ist ein follow-up-Frage aus meiner letzten Frage.

Einfache javascript-Prototyp Problem

Ich bin ein bisschen neu mit JavaScript prototype so sorry für den zweiten post.

Will ich weisen Sie das angeklickte element id zu den this.name array.

task.prototype.init=function(){  
      this.name=[];  //this.name array has to be defined here

        for (var i; i<5; i++){
            var Link=document.createElement('a');
                Link.innerHTML='click';
                Link.id=value[i];   //I want to assign the value to the this.name array
                Link.href='#'
                Link.onclick=this.changeName;
                document.body.appendChild(Link);
         }
}
task.prototype.changeName=function(){  

     //How do I push the this.id to the property this.name?

     //the code below won't work because this refer to the <a> element. 
     this.name.push(this.id);     

    return false;
    }

Tipps für die Aufgabe?

InformationsquelleAutor FlyingCat | 2012-12-21
Schreibe einen Kommentar