SitePoint Sponsor |
|
User Tag List
Results 1 to 3 of 3
Thread: How to addEventListener?
-
Sep 7, 2002, 13:52 #1
- Join Date
- Jul 2002
- Posts
- 95
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
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?
-
Sep 7, 2002, 13:59 #2
- Join Date
- Jul 2002
- Posts
- 95
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
I just found out. IE doesn't support addEventListener but uses attachEvent instead.
-
Sep 7, 2002, 20:14 #3
- Join Date
- Jul 1999
- Location
- SC, USA
- Posts
- 390
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Hey Rok
Check out this tutorial:
http://www.pageresource.com/dhtml/ryan/part4-7.html
aDogModerator at www.javascriptcity.com/forums/
Bookmarks