View Single Post
Old 09-07-2002, 10:06 PM   PM User | #1
Rok
New Coder

 
Join Date: Sep 2002
Posts: 20
Thanks: 0
Thanked 0 Times in 0 Posts
Rok is an unknown quantity at this point
How to addEventListener?

OK, lets make this easy . I wont go into details of my function, I would like to first see it work . So here's the thing:

I've read a small tutorial about addEventListener but it doesn't work for me. So what I want is this (well, that's not exactly what I want but I just want to know the concept first):

I have an image. I want when you click on it two alerts appear. Like this:
<img onclick="alert('a'); alert('b');">

But I don't want to do it thusly. I want to make it dynamically. So:
<img onclick="alert('a');">
and then something like:

document.getElementsByTagName('img')[0].addEventListener
but don't know the rest.

How to solve this?
Rok is offline   Reply With Quote