Javascript Universal way to know added new element

时光总嘲笑我的痴心妄想 提交于 2020-01-24 21:37:25

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!