我正在尝试将 onclick 功能附加到每个 a 标签。
我有
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;
}
有没有办法做到这一点?