Is it possible to append to innerHTML without destroying descendants' event listeners?

前端 未结 13 1196
悲哀的现实
悲哀的现实 2020-11-21 23:40

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 <

13条回答
  •  别那么骄傲
    2020-11-22 00:15

    Now, it is 2012, and jQuery has append and prepend functions that do exactly this, add content without effecting current content. Very useful.

提交回复
热议问题