Remove eventlistener in Javascript after event ocurred?

It should work with a named function. If your second approach does not work properly, try storing the initial listener into a variable, like this.

It should work with a named function. If your second approach does not work properly, try storing the initial listener into a variable, like this: var handler = function(event) { for(...) { removeEventListener('click', handler, false); } }; addEventListener('click', handler, false); Ps. If you care about speed, you may wish to consider using just one event handler.

You can put the handler into the parent element of the divs, and then delegate the event from there. With 24 handlers your current approach probably doesn't have a very big performance hit, but this is something you should keep in mind if it ever feels slow.

It worked! I wanna thank you so much! I tried to figur out all day long without any success – Woho87 Sep 16 '10 at 5:50.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions