[thelist] Javascript addEventListener fail

Barney Carroll barney.carroll at gmail.com
Tue Jan 13 10:07:53 CST 2009


Jason, I tried this after throwing the whole thing in led it to execute as
and when it occurred in the code — basically I was trying to make it
evaluate the statement. Which I now realise is silly.

Matt, thanks a lot for that. As it happens, I *can* get all the info I need
from the source element. I had no idea about event.srcElement — powerfully
wicked stuff. So much for evals ;)



Regards,
Barney Carroll
Web designer & front-end developer

t: +44 (0) 7594 506 381


2009/1/13 Matt Warden <mwarden at gmail.com>

> On Tue, Jan 13, 2009 at 10:40 AM, Barney Carroll
> <barney.carroll at gmail.com> wrote:
> > Here is the problematic line of script:
> >
> > th3s[i].addEventListener('click', 'changeTab('+i+')', false);
> >
> > This is inside a for loop, and the event needs to be evaluated — which I
> > can't seem to make it do. Firebug tells me that it "could not convert
> > JavaScript argument" on this line.
>
> Are you just trying to get a reference to the element that triggered
> changeTab()? You do not need to pass in 'i' for that.
>
> http://mattwarden.com/sandbox/getidfromeventhandler.js
>
> --
> Matt Warden
> Cincinnati, OH, USA
> http://mattwarden.com
>
>
> This email proudly and graciously contributes to entropy.
> --
>
> * * Please support the community that supports you.  * *
> http://evolt.org/help_support_evolt/
>
> For unsubscribe and other options, including the Tip Harvester
> and archives of thelist go to: http://lists.evolt.org
> Workers of the Web, evolt !
>



More information about the thelist mailing list