I have this code:
It works fine, but then I add one more line:Code:var container = document.getElementById( 'container' ); var url = document.createElement( 'a' ); url.setAttribute( 'id', 'dynamic' ); url.setAttribute( 'href', 'http://foo.bar' ); url.innerHTML = 'CLICKME!'; container.appendChild( url ); url.addEventListener( 'click', function( evt ) { evt.preventDefault(); alert( 'OK' ); }, false );
and it stops working. The event handler isn't called at all. Why is that?Code:container.innerHTML += '<br>';
Thanks.


Reply With Quote

Bookmarks