Witam

Podam kod którym tworzę dynamicznie div'y w klasie. Jak mogę zaimplementować zdarzenie onclick dla tworzonego div'a na podstawie mojego kodu? Podkeślam że jestem totalnym początkującym klepaczem.

this.iter = this.iter + 1;
//top = top + ttop;
this.div[this.iter] = document.createElement('div');
this.div[this.iter].id = idName+this.iter;
this.div[this.iter].style.backgroundColor = Backcolor;
this.div[this.iter].style.color = 'yellow';
this.div[this.iter].style.position = "absolute";
this.div[this.iter].style.pixelLeft= left;
this.div[this.iter].style.pixelTop= top;
this.div[this.iter].style.pixelWidth= width;
this.div[this.iter].style.pixelHeight= height;

a = document.createElement('a');
if(link!='') a.setAttribute('href','http://'+link);
a.appendChild(document.createTextNode(name));
a.style.color='white';
a.id="link";
this.div[this.iter].appendChild(a);
this.div[this.iter].style.visibility = "visible";
body = document.getElementById(this.divName.id);
body.appendChild(this.div[this.iter]);

pozdrawiam