I am trying to attach an onclick function to each tag.
I have
task.prototype.init=function(){ for (value in obj){ var Link=document.createElement('a'); Link.innerHTML='click'; Link.id=value; //I want to get the value Link.href='#' Link.onclick=this.changeName; document.body.appendChild(Link); } } task.prototype.changeName=function(){ //I want to get the clicked element id and I am not sure how to do it. return false; }
Is there any way to accomplish this?
javascript
Flyingcat
source share