Is it possible to append to innerHTML without destroying descendants' event listeners?
问题 In the following example code, I attach an onclick event handler to the span containing the text "foo". The handler is an anonymous function that pops up an alert() . However, if I assign to the parent node's innerHTML , this onclick event handler gets destroyed - clicking "foo" fails to pop up the alert box. Is this fixable? <html> <head> <script type="text/javascript"> function start () { myspan = document.getElementById("myspan"); myspan.onclick = function() { alert ("hi"); }; mydiv =