Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> [JavaScript] Dynamiczne tworzenie div i zdarzenie ONCLICK
pjamalia
post
Post #1





Grupa: Zarejestrowani
Postów: 77
Pomógł: 0
Dołączył: 1.11.2009

Ostrzeżenie: (0%)
-----


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
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 19.08.2025 - 09:58