Rok
09-07-2002, 10:06 PM
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?
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?