Evertjan, (and by extension also Raphael for mentioning that it doesn't work with innerHtml)

My wife just had a similar issue where she was trying to add an eventlistener to piece of html she had just inserted via innerHtml.
After a while she comes to me, because the eventlistener wasn't working and she already had come to the conclusion that the element wasn't in the DOM.
So.... 1+1=3 and there we go: happy wife, great life.

Appending the element to the DOM worked and she had no problem attaching an eventlistener to the new element from then on.
So, Oy says "Thanks!" to you both.