Ciao ragazzi, sono sempre io. Volevo sapere come si può accedere alle proprietà di un oggetto tramite l'invocazione di un metodo che gestisce un evento. Per esempio:
In pratica cliccando sul bottone vedi ritorna undefined... come mai?codice:<html> <head> <script> function test() { this.proprieta="prop"; this.bottone=document.createElement('button'); this.bottone.innerHTML="vedi"; document.getElementById('test').appendChild(this.bottone); this.bottone.onclick =function(e) { alert(this.proprieta); } } function inizia() { var testa=new test(); } </script> </head> <body onload="inizia()"> <div id="test"></div> </body> </html>

Rispondi quotando
