[Project_owners] [JS] addEventListener function parameter

Didier Ernotte didier at ernotte.com
Tue May 30 12:25:23 EDT 2006


Maybe?

button.setAttribute("ident", ixyzt);
button.addEventListener('click', function (event){ foo(event.target.getAttribute("ident")}, 'false');
ixyzt++;

Didier

Michael Bar-David <mbd1987 at gmail.com> wrote: OK...  the joy was premature. I steel have problems (probably I didn't
understand how to use it correctly).
I'm trying to dynamically add buttons to the page, and giving them numbers:
when clicking button1 it should use a function, and give it 1 as
parameter, the second is button2, an should pass 2 as parameter, and
so on.
this code make problems (I can't define what):

button.addEventListener('click', function (){ foo(ixyzt)}, 'false');
ixyzt++;

(ixyzt is a global variable)

thanks
Michael
_______________________________________________
Project_owners mailing list
Project_owners at mozdev.org
http://mozdev.org/mailman/listinfo/project_owners

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mozdev.org/pipermail/project_owners/attachments/20060530/445203d5/attachment.htm


More information about the Project_owners mailing list