问题
AddEventHandler in Javascript is for handling the events (like onclick) universally (i.e. on any element).
Is there a way to fire an event (don't know which kind) when a new element (i.e input, div, select, etc.) is being added to the page (through Ajax, jQuery, etc.)?
I've looked into the DOM documentation on dev mozilla but couldn't find anything. May be I'm not looking in the right pages.
回答1:
Is there a reason you want to know? If the reason is you want to add event handlers to new elements, you could use the "Live" functionality of jQuery instead.
来源:https://stackoverflow.com/questions/1121831/javascript-universal-way-to-know-added-new-element